diff --git a/src/poetry/installation/wheel_installer.py b/src/poetry/installation/wheel_installer.py index 16de86e3022..ab2e0a82f3e 100644 --- a/src/poetry/installation/wheel_installer.py +++ b/src/poetry/installation/wheel_installer.py @@ -94,7 +94,7 @@ def __init__(self, env: Env) -> None: ) def enable_bytecode_compilation(self, enable: bool = True) -> None: - self._destination.bytecode_optimization_levels = (1,) if enable else () + self._destination.bytecode_optimization_levels = (-1,) if enable else () def install(self, wheel: Path) -> None: with WheelFile.open(wheel) as source: diff --git a/tests/installation/test_wheel_installer.py b/tests/installation/test_wheel_installer.py index 7fc4826f940..b7b3d7c7c93 100644 --- a/tests/installation/test_wheel_installer.py +++ b/tests/installation/test_wheel_installer.py @@ -77,5 +77,7 @@ def test_enable_bytecode_compilation( if compile: assert cache_dir.exists() assert list(cache_dir.glob("*.pyc")) + assert not list(cache_dir.glob("*.opt-1.pyc")) + assert not list(cache_dir.glob("*.opt-2.pyc")) else: assert not cache_dir.exists()