Skip to content

Ensure packages are checked from penv #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 9, 2025
11 changes: 7 additions & 4 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,11 +1489,13 @@ def generate_mbedtls_bundle(sdk_config):


def install_python_deps():
PYTHON_EXE = env.subst("$PYTHONEXE")
UV_EXE = os.path.join(os.path.dirname(PYTHON_EXE), "uv" + (".exe" if IS_WINDOWS else ""))
def _get_installed_uv_packages(python_exe_path):
result = {}
try:
uv_output = subprocess.check_output([
"uv", "pip", "list", "--python", python_exe_path, "--format=json"
UV_EXE, "pip", "list", "--python", python_exe_path, "--format=json"
])
packages = json.loads(uv_output)
except (subprocess.CalledProcessError, json.JSONDecodeError, OSError) as e:
Expand Down Expand Up @@ -1540,7 +1542,7 @@ def _get_installed_uv_packages(python_exe_path):
# Use uv to install packages in the specific Python environment
env.Execute(
env.VerboseAction(
f'uv pip install --python "{python_exe_path}" {packages_str}',
f'"{UV_EXE}" pip install --python "{python_exe_path}" {packages_str}',
"Installing ESP-IDF's Python dependencies with uv",
)
)
Expand All @@ -1549,7 +1551,7 @@ def _get_installed_uv_packages(python_exe_path):
# Install windows-curses in the IDF Python environment
env.Execute(
env.VerboseAction(
f'uv pip install --python "{python_exe_path}" windows-curses',
f'"{UV_EXE}" pip install --python "{python_exe_path}" windows-curses',
"Installing windows-curses package with uv",
)
)
Expand Down Expand Up @@ -2140,7 +2142,8 @@ def idf_lib_copy(source, target, env):
pass
print("*** Copied compiled %s IDF libraries to Arduino framework ***" % idf_variant)

pio_exe_path = shutil.which("platformio"+(".exe" if IS_WINDOWS else ""))
PYTHON_EXE = env.subst("$PYTHONEXE")
pio_exe_path = os.path.join(os.path.dirname(PYTHON_EXE), "pio" + (".exe" if IS_WINDOWS else ""))
pio_cmd = env["PIOENV"]
env.Execute(
env.VerboseAction(
Expand Down
19 changes: 8 additions & 11 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
# Python dependencies required for the build process
python_deps = {
"uv": ">=0.1.0",
"platformio": ">=6.1.18",
"pyyaml": ">=6.0.2",
"rich-click": ">=1.8.6",
"zopfli": ">=0.2.2",
Expand Down Expand Up @@ -179,8 +180,7 @@ def install_python_deps():
[PYTHON_EXE, "-m", "pip", "install", "uv>=0.1.0", "-q", "-q", "-q"],
capture_output=True,
text=True,
timeout=30, # 30 second timeout
env=os.environ # Use current environment with venv Python
timeout=30 # 30 second timeout
)
if result.returncode != 0:
if result.stderr:
Expand All @@ -200,21 +200,20 @@ def install_python_deps():

def _get_installed_uv_packages():
"""
Get list of installed packages using uv.
Get list of installed packages in virtual env 'penv' using uv.

Returns:
dict: Dictionary of installed packages with versions
"""
result = {}
try:
cmd = [uv_executable, "pip", "list", "--format=json"]
cmd = [uv_executable, "pip", "list", f"--python={PYTHON_EXE}", "--format=json"]
result_obj = subprocess.run(
cmd,
capture_output=True,
text=True,
encoding='utf-8',
timeout=30, # 30 second timeout
env=os.environ # Use current environment with venv Python
timeout=30 # 30 second timeout
)

if result_obj.returncode == 0:
Expand Down Expand Up @@ -256,8 +255,7 @@ def _get_installed_uv_packages():
cmd,
capture_output=True,
text=True,
timeout=30, # 30 second timeout for package installation
env=os.environ # Use current environment with venv Python
timeout=30 # 30 second timeout for package installation
)

if result.returncode != 0:
Expand Down Expand Up @@ -290,8 +288,7 @@ def install_esptool():
subprocess.check_call(
[PYTHON_EXE, "-c", "import esptool"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
env=os.environ
stderr=subprocess.DEVNULL
)
return
except (subprocess.CalledProcessError, FileNotFoundError):
Expand All @@ -307,7 +304,7 @@ def install_esptool():
uv_executable, "pip", "install", "--quiet",
f"--python={PYTHON_EXE}",
"-e", esptool_repo_path
], env=os.environ)
])

return

Expand Down