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: poetry env broken on Windows (#4615) #4682

Closed
wants to merge 1 commit into from
Closed
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 poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ def _bin(self, bin: str) -> str:
# a base Python install.
if self._is_windows:
if not bin.endswith(".exe"):
bin_path = self._bin_dir / (bin + ".exe")
bin_path = self._path / (bin + ".exe")
else:
bin_path = self._path / bin

Expand Down
21 changes: 21 additions & 0 deletions tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,27 @@ def test_env_finds_the_correct_executables(tmp_dir, manager):
assert Path(venv.python).name == expected_executable
assert Path(venv.pip).name.startswith(expected_pip_executable.split(".")[0])

@pytest.mark.skipif(os.name != "nt", reason="Testing functionality that is only relevant on Windows")
def test_env_finds_python_executable_in_base_path_on_windows(tmp_dir, manager):
venv_path = Path(tmp_dir) / "Virtual Env"
manager.build_venv(str(venv_path), with_pip=True)
venv = VirtualEnv(venv_path)

executable = "python.exe"

bin_dir_path = venv._bin_dir.joinpath(executable)
base_dir_path = venv._path.joinpath(executable)

if bin_dir_path.exists():
if base_dir_path.exists():
bin_dir_path.unlink()
else:
bin_dir_path.rename(base_dir_path)

venv = VirtualEnv(venv_path)

assert Path(venv.python) == base_dir_path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this test fails on Python 3.6 on Windows, so I spoke a little too soon. Can we take a look at that failure and get it corrected?



def test_env_finds_the_correct_executables_for_generic_env(tmp_dir, manager):
venv_path = Path(tmp_dir) / "Virtual Env"
Expand Down