Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fallback to other interpreters when specifying a patchlevel. #3475

Merged
merged 1 commit into from
Nov 15, 2021
Merged
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/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def create_venv(
supported_python
):
continue
elif not supported_python.allows_all(
elif not supported_python.allows_any(
parse_constraint(python_to_try + ".*")
):
continue
Expand Down
32 changes: 32 additions & 0 deletions tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,3 +1093,35 @@ def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager):

assert Path(venv.python).name == expected_executable
assert Path(venv.pip).name == expected_pip_executable


def test_create_venv_accepts_fallback_version_w_nonzero_patchlevel(
manager, poetry, config, mocker, config_virtualenvs_path
):
if "VIRTUAL_ENV" in os.environ:
del os.environ["VIRTUAL_ENV"]

poetry.package.python_versions = "~3.5.1"
venv_name = manager.generate_env_name("simple-project", str(poetry.file.parent))

check_output = mocker.patch(
"subprocess.check_output",
side_effect=lambda cmd, *args, **kwargs: str(
"3.5.12" if "python3.5" in cmd else "3.7.1"
),
)
m = mocker.patch(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
)

manager.create_venv(NullIO())

assert check_output.called
m.assert_called_with(
config_virtualenvs_path / "{}-py3.5".format(venv_name),
executable="python3.5",
flags={"always-copy": False, "system-site-packages": False},
with_pip=True,
with_setuptools=True,
with_wheel=True,
)