Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/installer/destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _compile_bytecode(self, scheme: Scheme, record: RecordEntry) -> None:

for level in self.bytecode_optimization_levels:
compileall.compile_file(
target_path, optimize=level, quiet=1, ddir=dir_path_to_embed
target_path, optimize=level, quiet=2, ddir=dir_path_to_embed
)

def finalize_installation(
Expand Down
27 changes: 27 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import sys
import types

import pytest

Expand Down Expand Up @@ -90,6 +92,31 @@ def test_main_no_pyc(fancy_wheel, tmp_path):
assert set(installed_pyc_files) == set()


def test_main_silences_bytecode_compile_failures(
fancy_wheel, tmp_path, monkeypatch, capsys
):
calls = []

def fake_compile_file(*args, **kwargs):
calls.append((args, kwargs))
if kwargs["quiet"] != 2:
sys.stderr.write("*** Error compiling test module...\n")
return False

monkeypatch.setitem(
sys.modules, "compileall", types.SimpleNamespace(compile_file=fake_compile_file)
)

destdir = tmp_path / "dest"

main([str(fancy_wheel), "-d", str(destdir)], "python -m installer")

captured = capsys.readouterr()
assert captured.err == ""
assert calls
assert all(kwargs["quiet"] == 2 for _, kwargs in calls)


@pytest.mark.parametrize(
"validation_part",
["all", "entries", "none"],
Expand Down
Loading