Skip to content

Commit 355f503

Browse files
authored
Ensure packages are checked from penv (#253)
* use full path for uv and pio * Install Platformio in penv (needed for HybridCompile) when missing
1 parent ab777b9 commit 355f503

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

builder/frameworks/espidf.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,11 +1489,13 @@ def generate_mbedtls_bundle(sdk_config):
14891489

14901490

14911491
def install_python_deps():
1492+
PYTHON_EXE = env.subst("$PYTHONEXE")
1493+
UV_EXE = os.path.join(os.path.dirname(PYTHON_EXE), "uv" + (".exe" if IS_WINDOWS else ""))
14921494
def _get_installed_uv_packages(python_exe_path):
14931495
result = {}
14941496
try:
14951497
uv_output = subprocess.check_output([
1496-
"uv", "pip", "list", "--python", python_exe_path, "--format=json"
1498+
UV_EXE, "pip", "list", "--python", python_exe_path, "--format=json"
14971499
])
14981500
packages = json.loads(uv_output)
14991501
except (subprocess.CalledProcessError, json.JSONDecodeError, OSError) as e:
@@ -1540,7 +1542,7 @@ def _get_installed_uv_packages(python_exe_path):
15401542
# Use uv to install packages in the specific Python environment
15411543
env.Execute(
15421544
env.VerboseAction(
1543-
f'uv pip install --python "{python_exe_path}" {packages_str}',
1545+
f'"{UV_EXE}" pip install --python "{python_exe_path}" {packages_str}',
15441546
"Installing ESP-IDF's Python dependencies with uv",
15451547
)
15461548
)
@@ -1549,7 +1551,7 @@ def _get_installed_uv_packages(python_exe_path):
15491551
# Install windows-curses in the IDF Python environment
15501552
env.Execute(
15511553
env.VerboseAction(
1552-
f'uv pip install --python "{python_exe_path}" windows-curses',
1554+
f'"{UV_EXE}" pip install --python "{python_exe_path}" windows-curses',
15531555
"Installing windows-curses package with uv",
15541556
)
15551557
)
@@ -2140,7 +2142,8 @@ def idf_lib_copy(source, target, env):
21402142
pass
21412143
print("*** Copied compiled %s IDF libraries to Arduino framework ***" % idf_variant)
21422144

2143-
pio_exe_path = shutil.which("platformio"+(".exe" if IS_WINDOWS else ""))
2145+
PYTHON_EXE = env.subst("$PYTHONEXE")
2146+
pio_exe_path = os.path.join(os.path.dirname(PYTHON_EXE), "pio" + (".exe" if IS_WINDOWS else ""))
21442147
pio_cmd = env["PIOENV"]
21452148
env.Execute(
21462149
env.VerboseAction(

builder/main.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
# Python dependencies required for the build process
5050
python_deps = {
5151
"uv": ">=0.1.0",
52+
"platformio": ">=6.1.18",
5253
"pyyaml": ">=6.0.2",
5354
"rich-click": ">=1.8.6",
5455
"zopfli": ">=0.2.2",
@@ -179,8 +180,7 @@ def install_python_deps():
179180
[PYTHON_EXE, "-m", "pip", "install", "uv>=0.1.0", "-q", "-q", "-q"],
180181
capture_output=True,
181182
text=True,
182-
timeout=30, # 30 second timeout
183-
env=os.environ # Use current environment with venv Python
183+
timeout=30 # 30 second timeout
184184
)
185185
if result.returncode != 0:
186186
if result.stderr:
@@ -200,21 +200,20 @@ def install_python_deps():
200200

201201
def _get_installed_uv_packages():
202202
"""
203-
Get list of installed packages using uv.
203+
Get list of installed packages in virtual env 'penv' using uv.
204204
205205
Returns:
206206
dict: Dictionary of installed packages with versions
207207
"""
208208
result = {}
209209
try:
210-
cmd = [uv_executable, "pip", "list", "--format=json"]
210+
cmd = [uv_executable, "pip", "list", f"--python={PYTHON_EXE}", "--format=json"]
211211
result_obj = subprocess.run(
212212
cmd,
213213
capture_output=True,
214214
text=True,
215215
encoding='utf-8',
216-
timeout=30, # 30 second timeout
217-
env=os.environ # Use current environment with venv Python
216+
timeout=30 # 30 second timeout
218217
)
219218

220219
if result_obj.returncode == 0:
@@ -256,8 +255,7 @@ def _get_installed_uv_packages():
256255
cmd,
257256
capture_output=True,
258257
text=True,
259-
timeout=30, # 30 second timeout for package installation
260-
env=os.environ # Use current environment with venv Python
258+
timeout=30 # 30 second timeout for package installation
261259
)
262260

263261
if result.returncode != 0:
@@ -290,8 +288,7 @@ def install_esptool():
290288
subprocess.check_call(
291289
[PYTHON_EXE, "-c", "import esptool"],
292290
stdout=subprocess.DEVNULL,
293-
stderr=subprocess.DEVNULL,
294-
env=os.environ
291+
stderr=subprocess.DEVNULL
295292
)
296293
return
297294
except (subprocess.CalledProcessError, FileNotFoundError):
@@ -307,7 +304,7 @@ def install_esptool():
307304
uv_executable, "pip", "install", "--quiet",
308305
f"--python={PYTHON_EXE}",
309306
"-e", esptool_repo_path
310-
], env=os.environ)
307+
])
311308

312309
return
313310

0 commit comments

Comments
 (0)