diff --git a/poetry/utils/env.py b/poetry/utils/env.py index b1cff78c215..bd23a780cf3 100644 --- a/poetry/utils/env.py +++ b/poetry/utils/env.py @@ -923,6 +923,7 @@ class Env(object): def __init__(self, path, base=None): # type: (Path, Optional[Path]) -> None self._is_windows = sys.platform == "win32" + self._is_conda = bool(os.environ.get("CONDA_DEFAULT_ENV")) self._path = path bin_dir = "bin" if not self._is_windows else "Scripts" @@ -1075,13 +1076,16 @@ def get_base_prefix(cls): # type: () -> str return sys.prefix - def find_executables(self): # type: () -> None + def _find_python_executable(self) -> None: + bin_dir = self._bin_dir + + if self._is_windows and self._is_conda: + bin_dir = self._path + python_executables = sorted( - [ - p.name - for p in self._bin_dir.glob("python*") - if re.match(r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name) - ] + p.name + for p in bin_dir.glob("python*") + if re.match(r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name) ) if python_executables: executable = python_executables[0] @@ -1090,12 +1094,11 @@ def find_executables(self): # type: () -> None self._executable = executable + def _find_pip_executable(self) -> None: pip_executables = sorted( - [ - p.name - for p in self._bin_dir.glob("pip*") - if re.match(r"pip(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name) - ] + p.name + for p in self._bin_dir.glob("pip*") + if re.match(r"pip(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name) ) if pip_executables: pip_executable = pip_executables[0] @@ -1104,6 +1107,10 @@ def find_executables(self): # type: () -> None self._pip_executable = pip_executable + def find_executables(self): # type: () -> None + self._find_python_executable() + self._find_pip_executable() + def get_version_info(self): # type: () -> Tuple[int] raise NotImplementedError() @@ -1231,7 +1238,7 @@ def _bin(self, bin): # type: (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