Skip to content

Commit

Permalink
Correct bin paths in CondaEnv for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolker-KU committed Dec 25, 2021
1 parent 26f2a0d commit a364bdf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions nox/virtualenv.py
Expand Up @@ -231,9 +231,16 @@ def _clean_location(self) -> bool:
@property
def bin_paths(self) -> List[str]:
"""Returns the location of the conda env's bin folder."""
# see https://docs.anaconda.com/anaconda/user-guide/tasks/integration/python-path/#examples
# see https://github.com/conda/conda/blob/f60f0f1643af04ed9a51da3dd4fa242de81e32f4/conda/activate.py#L563-L572
if _SYSTEM == "Windows":
return [self.location, os.path.join(self.location, "Scripts")]
return [
self.location,
os.path.join(self.location, "Library", "mingw-w64", "bin"),
os.path.join(self.location, "Library", "usr", "bin"),
os.path.join(self.location, "Library", "bin"),
os.path.join(self.location, "Scripts"),
os.path.join(self.location, "bin"),
]
else:
return [os.path.join(self.location, "bin")]

Expand Down
9 changes: 8 additions & 1 deletion tests/test_virtualenv.py
Expand Up @@ -230,7 +230,14 @@ def test_conda_env_create_verbose(make_conda):
@mock.patch("nox.virtualenv._SYSTEM", new="Windows")
def test_condaenv_bin_windows(make_conda):
venv, dir_ = make_conda()
assert [dir_.strpath, dir_.join("Scripts").strpath] == venv.bin_paths
assert [
dir_.strpath,
dir_.join("Library", "mingw-w64", "bin").strpath,
dir_.join("Library", "usr", "bin").strpath,
dir_.join("Library", "bin").strpath,
dir_.join("Scripts").strpath,
dir_.join("bin").strpath,
] == venv.bin_paths


@pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")
Expand Down

0 comments on commit a364bdf

Please sign in to comment.