Skip to content

Commit

Permalink
add alternative bin search path in case of conda env under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
finswimmer committed Jan 8, 2022
1 parent b4f13de commit 8fb4477
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ class Env:
def __init__(self, path: Path, base: Optional[Path] = None) -> None:
self._is_windows = sys.platform == "win32"
self._is_mingw = sysconfig.get_platform().startswith("mingw")
self._is_conda = bool(os.environ.get("CONDA_DEFAULT_ENV"))

if not self._is_windows or self._is_mingw:
bin_dir = "bin"
Expand Down Expand Up @@ -1134,9 +1135,14 @@ def parent_env(self) -> "GenericEnv":
return GenericEnv(self.base, child_env=self)

def find_executables(self) -> None:
if self._is_windows and self._is_conda:
python_bin_dir = self._bin_dir.parent
else:
python_bin_dir = self._bin_dir

python_executables = sorted(
p.name
for p in self._bin_dir.glob("python*")
for p in python_bin_dir.glob("python*")
if re.match(r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name)
)
if python_executables:
Expand Down Expand Up @@ -1408,6 +1414,8 @@ def _bin(self, bin: str) -> str:

if bin_path.exists():
return str(bin_path)
elif Path(self._bin_dir.parent / (bin + ".exe")).exists():
return str(Path(self._bin_dir.parent / (bin + ".exe")))

return bin

Expand Down

0 comments on commit 8fb4477

Please sign in to comment.