fix: set UV_PYTHON for before_build on Linux when using uv (#2830)

Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>
This commit is contained in:
agriya khetarpal
2026-05-05 05:39:14 +05:30
committed by GitHub
co-authored by Matthieu Darbois
parent d593457f60
commit a76fca878d
+10 -1
View File
@@ -265,7 +265,16 @@ def build_in_container(
project=container_project_path,
package=container_package_dir,
)
container.call(["sh", "-c", before_build_prepared], env=env)
before_build_env = env.copy()
if use_uv:
# On Linux, no virtualenv is created for the build environment
# (unlike macOS/Windows, where one is set up before before_build
# runs). uv requires either an active venv or an explicit Python
# target to install packages. Pin UV_PYTHON to the exact interpreter
# for this build so that `uv pip install` works in before_build
# without requiring users to pass --system.
before_build_env["UV_PYTHON"] = str(python_bin / "python")
container.call(["sh", "-c", before_build_prepared], env=before_build_env)
log.step("Building wheel...")