Skip to content

Commit 6f295da

Browse files
authored
docs: add uv sync example (#864)
1 parent 57825e8 commit 6f295da

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/cookbook.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ Even more so with a sprinkling of Nox:
117117
Now a simple ``nox -s release -- patch`` will automate your release (provided you have Bump2Version set up to change your files). This is especially powerful if you have a CI/CD pipeline set up!
118118

119119

120+
Using a lockfile
121+
^^^^^^^^^^^^^^^^
122+
123+
If you use a tool like ``uv`` to lock your dependencies, you can use that inside a nox session. Here's an example:
124+
125+
.. code-block:: python
126+
127+
@nox.session(venv_backend="uv")
128+
def tests(session: nox.Session) -> None:
129+
"""
130+
Run the unit and regular tests.
131+
"""
132+
session.run_install(
133+
"uv",
134+
"sync",
135+
"--extra=test",
136+
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
137+
)
138+
session.run("pytest", *session.posargs)
139+
140+
141+
Here we run ``uv sync`` on the nox virtual environment. Other useful flags might include ``--frozen`` (won't touch the lockfile) and ``--inexact`` (will allow you to install other packages as well).
142+
143+
120144
Generating a matrix with GitHub Actions
121145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
122146

0 commit comments

Comments
 (0)