@@ -1065,6 +1065,7 @@ class Env:
10651065 def __init__ (self , path : Path , base : Optional [Path ] = None ) -> None :
10661066 self ._is_windows = sys .platform == "win32"
10671067 self ._is_mingw = sysconfig .get_platform ().startswith ("mingw" )
1068+ self ._is_conda = bool (os .environ .get ("CONDA_DEFAULT_ENV" ))
10681069
10691070 if not self ._is_windows or self ._is_mingw :
10701071 bin_dir = "bin"
@@ -1125,10 +1126,15 @@ def marker_env(self) -> Dict[str, Any]:
11251126 def parent_env (self ) -> "GenericEnv" :
11261127 return GenericEnv (self .base , child_env = self )
11271128
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+
11291135 python_executables = sorted (
11301136 p .name
1131- for p in self . _bin_dir .glob ("python*" )
1137+ for p in bin_dir .glob ("python*" )
11321138 if re .match (r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$" , p .name )
11331139 )
11341140 if python_executables :
@@ -1138,6 +1144,7 @@ def find_executables(self) -> None:
11381144
11391145 self ._executable = executable
11401146
1147+ def _find_pip_executable (self ) -> None :
11411148 pip_executables = sorted (
11421149 p .name
11431150 for p in self ._bin_dir .glob ("pip*" )
@@ -1150,6 +1157,10 @@ def find_executables(self) -> None:
11501157
11511158 self ._pip_executable = pip_executable
11521159
1160+ def find_executables (self ) -> None :
1161+ self ._find_python_executable ()
1162+ self ._find_pip_executable ()
1163+
11531164 def get_embedded_wheel (self , distribution : str ) -> Path :
11541165 return get_embed_wheel (
11551166 distribution , f"{ self .version_info [0 ]} .{ self .version_info [1 ]} "
@@ -1395,7 +1406,7 @@ def _bin(self, bin: str) -> str:
13951406 # the root of the env path.
13961407 if self ._is_windows :
13971408 if not bin .endswith (".exe" ):
1398- bin_path = self ._bin_dir / (bin + ".exe" )
1409+ bin_path = self ._path / (bin + ".exe" )
13991410 else :
14001411 bin_path = self ._path / bin
14011412
0 commit comments