@@ -1065,6 +1065,7 @@ class Env:
1065
1065
def __init__ (self , path : Path , base : Optional [Path ] = None ) -> None :
1066
1066
self ._is_windows = sys .platform == "win32"
1067
1067
self ._is_mingw = sysconfig .get_platform ().startswith ("mingw" )
1068
+ self ._is_conda = bool (os .environ .get ("CONDA_DEFAULT_ENV" ))
1068
1069
1069
1070
if not self ._is_windows or self ._is_mingw :
1070
1071
bin_dir = "bin"
@@ -1125,10 +1126,15 @@ def marker_env(self) -> Dict[str, Any]:
1125
1126
def parent_env (self ) -> "GenericEnv" :
1126
1127
return GenericEnv (self .base , child_env = self )
1127
1128
1128
- def find_executables (self ) -> None :
1129
+ def _find_python_executable (self ) -> None :
1130
+ bin_dir = self ._bin_dir
1131
+
1132
+ if self ._is_windows and self ._is_conda :
1133
+ bin_dir = self ._path
1134
+
1129
1135
python_executables = sorted (
1130
1136
p .name
1131
- for p in self . _bin_dir .glob ("python*" )
1137
+ for p in bin_dir .glob ("python*" )
1132
1138
if re .match (r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$" , p .name )
1133
1139
)
1134
1140
if python_executables :
@@ -1138,6 +1144,7 @@ def find_executables(self) -> None:
1138
1144
1139
1145
self ._executable = executable
1140
1146
1147
+ def _find_pip_executable (self ) -> None :
1141
1148
pip_executables = sorted (
1142
1149
p .name
1143
1150
for p in self ._bin_dir .glob ("pip*" )
@@ -1150,6 +1157,10 @@ def find_executables(self) -> None:
1150
1157
1151
1158
self ._pip_executable = pip_executable
1152
1159
1160
+ def find_executables (self ) -> None :
1161
+ self ._find_python_executable ()
1162
+ self ._find_pip_executable ()
1163
+
1153
1164
def get_embedded_wheel (self , distribution : str ) -> Path :
1154
1165
return get_embed_wheel (
1155
1166
distribution , f"{ self .version_info [0 ]} .{ self .version_info [1 ]} "
@@ -1395,7 +1406,7 @@ def _bin(self, bin: str) -> str:
1395
1406
# the root of the env path.
1396
1407
if self ._is_windows :
1397
1408
if not bin .endswith (".exe" ):
1398
- bin_path = self ._bin_dir / (bin + ".exe" )
1409
+ bin_path = self ._path / (bin + ".exe" )
1399
1410
else :
1400
1411
bin_path = self ._path / bin
1401
1412
0 commit comments