@@ -109,24 +109,18 @@ def setup_pipenv_in_package():
109
109
110
110
111
111
def setup_python_paths ():
112
- """
113
- Setup Python module search paths using the penv_dir.
114
- """
112
+ """Setup Python module search paths using the penv_dir."""
115
113
# Add penv_dir to module search path
116
114
site .addsitedir (penv_dir )
117
115
118
116
# Add site-packages directory
117
+ python_ver = f"python{ sys .version_info .major } .{ sys .version_info .minor } "
119
118
site_packages = (
120
119
os .path .join (penv_dir , "Lib" , "site-packages" ) if IS_WINDOWS
121
- else next (
122
- (os .path .join (penv_dir , "lib" , d , "site-packages" )
123
- for d in os .listdir (os .path .join (penv_dir , "lib" ))
124
- if d .startswith ("python" )),
125
- None
126
- ) if os .path .isdir (os .path .join (penv_dir , "lib" )) else None
120
+ else os .path .join (penv_dir , "lib" , python_ver , "site-packages" )
127
121
)
128
122
129
- if site_packages and os .path .isdir (site_packages ):
123
+ if os .path .isdir (site_packages ):
130
124
site .addsitedir (site_packages )
131
125
132
126
@@ -313,9 +307,9 @@ def install_esptool():
313
307
f"--python={ PYTHON_EXE } " ,
314
308
"-e" , esptool_repo_path
315
309
], env = os .environ )
316
-
310
+
317
311
return
318
-
312
+
319
313
except subprocess .CalledProcessError as e :
320
314
print (f"Error: Failed to install esptool: { e } " )
321
315
sys .exit (1 )
0 commit comments