Skip to content

Commit 4c20c3d

Browse files
committed
WIP: Force uv to use sessions interpreter
1 parent 923c6c8 commit 4c20c3d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

noxfile.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ def session_install_uv(
3434
install_docs: bool = False,
3535
) -> None:
3636
"""Install root project into the session's virtual environment using uv."""
37-
env = {
38-
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
39-
"UV_PYTHON": sys.executable, # Override any external UV_PYTHON setting
40-
}
37+
env = os.environ.copy()
38+
env.update(
39+
{
40+
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
41+
"UV_PYTHON": sys.executable, # Force uv to use the session's interpreter
42+
}
43+
)
4144

4245
args = ["uv", "sync", "--frozen"]
4346
if not install_project:
@@ -52,7 +55,13 @@ def session_install_uv(
5255

5356
def session_install_uv_package(session: Session, packages: list[str]) -> None:
5457
"""Install packages into the session's virtual environment using uv lockfile."""
55-
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
58+
env = os.environ.copy()
59+
env.update(
60+
{
61+
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
62+
"UV_PYTHON": sys.executable,
63+
}
64+
)
5665

5766
# Export requirements.txt to session temp dir using uv with locked dependencies
5867
requirements_tmp = str(Path(session.create_tmp()) / "requirements.txt")

0 commit comments

Comments
 (0)