Commit 85ff2147 by finswimmer Committed by Bjorn Neergaard

add alternative bin search path in case of conda env under windows

parent 20587f1e
...@@ -1065,6 +1065,7 @@ class Env: ...@@ -1065,6 +1065,7 @@ class Env:
def __init__(self, path: Path, base: Optional[Path] = None) -> None: def __init__(self, path: Path, base: Optional[Path] = None) -> None:
self._is_windows = sys.platform == "win32" self._is_windows = sys.platform == "win32"
self._is_mingw = sysconfig.get_platform().startswith("mingw") 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: if not self._is_windows or self._is_mingw:
bin_dir = "bin" bin_dir = "bin"
...@@ -1125,10 +1126,15 @@ class Env: ...@@ -1125,10 +1126,15 @@ class Env:
def parent_env(self) -> "GenericEnv": def parent_env(self) -> "GenericEnv":
return GenericEnv(self.base, child_env=self) return GenericEnv(self.base, child_env=self)
def find_executables(self) -> 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( python_executables = sorted(
p.name p.name
for p in self._bin_dir.glob("python*") for p in bin_dir.glob("python*")
if re.match(r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name) if re.match(r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name)
) )
if python_executables: if python_executables:
...@@ -1138,6 +1144,7 @@ class Env: ...@@ -1138,6 +1144,7 @@ class Env:
self._executable = executable self._executable = executable
def _find_pip_executable(self) -> None:
pip_executables = sorted( pip_executables = sorted(
p.name p.name
for p in self._bin_dir.glob("pip*") for p in self._bin_dir.glob("pip*")
...@@ -1150,6 +1157,10 @@ class Env: ...@@ -1150,6 +1157,10 @@ class Env:
self._pip_executable = pip_executable self._pip_executable = pip_executable
def find_executables(self) -> None:
self._find_python_executable()
self._find_pip_executable()
def get_embedded_wheel(self, distribution: str) -> Path: def get_embedded_wheel(self, distribution: str) -> Path:
return get_embed_wheel( return get_embed_wheel(
distribution, f"{self.version_info[0]}.{self.version_info[1]}" distribution, f"{self.version_info[0]}.{self.version_info[1]}"
...@@ -1395,7 +1406,7 @@ class Env: ...@@ -1395,7 +1406,7 @@ class Env:
# the root of the env path. # the root of the env path.
if self._is_windows: if self._is_windows:
if not bin.endswith(".exe"): if not bin.endswith(".exe"):
bin_path = self._bin_dir / (bin + ".exe") bin_path = self._path / (bin + ".exe")
else: else:
bin_path = self._path / bin bin_path = self._path / bin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment