From 8fb44777b5e247c2b1ccc073f934fef79aa6ee7c Mon Sep 17 00:00:00 2001 From: finswimmer Date: Sat, 8 Jan 2022 17:04:26 +0100 Subject: [PATCH] add alternative bin search path in case of conda env under windows --- src/poetry/utils/env.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/poetry/utils/env.py b/src/poetry/utils/env.py index 5c10d0ef000..9f446f3a5f9 100644 --- a/src/poetry/utils/env.py +++ b/src/poetry/utils/env.py @@ -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" @@ -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: @@ -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