Skip to content

Commit

Permalink
fix: poetry env broken on Windows (#4615)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Bowles committed Nov 1, 2021
1 parent 5dcf24d commit 2f21d52
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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


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

0 comments on commit 2f21d52

Please sign in to comment.