Repository navigation
Pass uv environment variables to build requirement installs - #438
Merged
Merged
Conversation
install_reqs only copied variables starting with PIP from build_env into the environment used to install build requirements into the isolated build environment. When uv is the installer, UV_ variables set in build_env, such as the UV_BUILD_CONSTRAINT that recipe builds set, never reached it. Copy variables starting with UV_ as well. The prefix includes the underscore so that unrelated variables that happen to start with UV are not picked up. Fixes pyodide#413
Thanatos9404
force-pushed
the
install-reqs-uv-env
branch
from
October 16, 2026 06:31
1fe45e4 to
24af42d
Compare
ryanking13
approved these changes
Oct 16, 2026
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #413
install_reqscopies only the variables starting withPIPfrombuild_envinto the environment thatenv.install()runs in. When uv is the installer,buildrunsuv pip installwith that environment, soUV_variables inbuild_envnever reached it. That includes theUV_BUILD_CONSTRAINTthatRecipeBuildersets next toPIP_CONSTRAINTandPIP_BUILD_CONSTRAINT(#389).This passes variables starting with
UV_as well. I usedUV_with the underscore so that unrelated names that happen to start withUV(for exampleUVICORN_PORT) are not picked up. This is the only place that filters on these prefixes, so I kept it inline rather than adding a helper.I also checked it with a real uv-backed isolated env (uv 0.13.1 from
build[uv], Python 3.13):install_reqsinstallingsix, with a constraints file pinningsix==1.16.0passed throughbuild_env.build_envmainUV_CONSTRAINTUV_BUILD_CONSTRAINTPIP_CONSTRAINTSo the variables now reach uv. uv also accepts every value form that
RecipeBuilder._create_constraints_fileproduces (an empty string, a path with a leading space, two space-separated paths), so passingUV_BUILD_CONSTRAINTthrough does not break installs.One thing this shows, though:
UV_BUILD_CONSTRAINTonly applies to the build dependencies of source distributions that uv builds during the install, not to the build requirements themselves, while pip appliesPIP_CONSTRAINTto them. The existingtest_build_constraintshows the same thing when uv is installed: the recipe constrainssetuptools < 75, and the test gets setuptools 84.0.0, both onmainand on this branch. Addingbuild_env["UV_CONSTRAINT"] = constraints_filenext toUV_BUILD_CONSTRAINTinRecipeBuilder._compilemakes it pass on this branch. Onmain, that line alone is not enough, because the variable never reaches uv. I left theUV_CONSTRAINTline out to keep this PR to the issue, but I'm happy to add it here or in a follow-up.Checklist
New test
test_install_reqs_propagates_pip_and_uv_envinpyodide_build/tests/test_pypabuild.py. It replacesenv.installwith one that recordsos.environ, then checks that thePIP_andUV_values frombuild_envare there when it runs, thatUVICORN_PORTandCFLAGSfrombuild_envare not, and that the environment is restored afterwards. It fails onmain(UV_BUILD_CONSTRAINTis missing) and passes with this change.Checks run locally:
pytest pyodide_build -m "not integration"on Python 3.13 (Ubuntu under WSL), installed as in CI: 410 passed, 1 more than onmain. 15 other tests fail in the same way onmain, because of this machine's setup (no Node.js fornpx prettier, and thepyodidescript is not onPATH).ruff checkandruff format --check(0.15.20, as pinned in pre-commit),mypy2.1.0 andcodespellon the changed files: clean.