-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Having a .python-version
or .python-versions
file breaks Python version definition in Nox with uv backend
#931
Comments
You can add |
❯ nox
nox > Running session py_ver-3.8
nox > Creating virtual environment (uv) using python3.8 in .nox/py_ver-3-8
nox > uv sync --no-group=dev --no-config
Using CPython 3.13.2
Removed virtual environment at: .nox/py_ver-3-8
Creating virtual environment at: .nox/py_ver-3-8
Resolved 13 packages in 1ms
Audited in 0.02ms
nox > python --version
Python 3.13.2
nox > Session py_ver-3.8 was successful.
nox > Running session py_ver-3.9
nox > Creating virtual environment (uv) using python3.9 in .nox/py_ver-3-9
nox > uv sync --no-group=dev --no-config
Using CPython 3.13.2
Removed virtual environment at: .nox/py_ver-3-9
Creating virtual environment at: .nox/py_ver-3-9
Resolved 13 packages in 1ms
Audited in 0.02ms
nox > python --version
Python 3.13.2
nox > Session py_ver-3.9 was successful.
nox > Ran multiple sessions:
nox > * py_ver-3.8: success
nox > * py_ver-3.9: success |
Is your Another way to do it is to set it via @nox.session(python=["3.8", "3.9"])
def py_ver(session: nox.Session) -> None:
session.run_install(
"uv",
"sync",
"--no-default-groups",
f"-p{session.virtualenv.location}",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("python", "--version") |
It was a bad |
Current Behavior
If there is a
.python-version
or.python-versions
file in the project's root, uv will default to that after auv sync
, and ignore the Python version specified in the Noxfile.Expected Behavior
It should ignore these files and use the Python version defined by Nox.
Steps To Reproduce
uv init nox-uv
code nox-uv
uv add --dev "nox[uv]"
uv sync
noxfile.py
in the root:nox
Environment
Anything else?
I'm following the official Nox recipe for uv found here:
https://nox.thea.codes/en/stable/cookbook.html#using-a-lockfile
I believe this may be solved by adapting the recipe.
The text was updated successfully, but these errors were encountered: