nox-uv 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nox_uv/__init__.py +106 -0
- nox_uv/py.typed +0 -0
- nox_uv-0.1.0.dist-info/METADATA +34 -0
- nox_uv-0.1.0.dist-info/RECORD +6 -0
- nox_uv-0.1.0.dist-info/WHEEL +4 -0
- nox_uv-0.1.0.dist-info/licenses/LICENSE.txt +21 -0
nox_uv/__init__.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
import functools
|
|
5
|
+
from typing import Any, Callable, TypeVar
|
|
6
|
+
|
|
7
|
+
import nox
|
|
8
|
+
|
|
9
|
+
R = TypeVar("R")
|
|
10
|
+
|
|
11
|
+
Python = Sequence[str] | str | bool | None
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def session(
|
|
15
|
+
*args: Any,
|
|
16
|
+
python: Python | None = None,
|
|
17
|
+
reuse_venv: bool | None = None,
|
|
18
|
+
name: str | None = None,
|
|
19
|
+
venv_backend: Any | None = None,
|
|
20
|
+
venv_params: Sequence[str] = (),
|
|
21
|
+
tags: Sequence[str] | None = None,
|
|
22
|
+
default: bool = True,
|
|
23
|
+
requires: Sequence[str] | None = None,
|
|
24
|
+
uv_groups: Sequence[str] = (),
|
|
25
|
+
uv_extras: Sequence[str] = (),
|
|
26
|
+
uv_all_extras: bool = False,
|
|
27
|
+
uv_all_groups: bool = False,
|
|
28
|
+
) -> Callable[..., R]:
|
|
29
|
+
"""Drop-in replacement for the :func:`nox.session` decorator.
|
|
30
|
+
|
|
31
|
+
Use this decorator instead of ``@nox.session``. Session functions are passed
|
|
32
|
+
:class:`Session` instead of :class:`nox.sessions.Session`; otherwise, the
|
|
33
|
+
decorators work exactly the same.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
args: Positional arguments are forwarded to ``nox.session``.
|
|
37
|
+
kwargs: Keyword arguments are forwarded to ``nox.session``.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
The decorated session function.
|
|
41
|
+
"""
|
|
42
|
+
if not args:
|
|
43
|
+
return functools.partial(
|
|
44
|
+
session,
|
|
45
|
+
python=python,
|
|
46
|
+
reuse_venv=reuse_venv,
|
|
47
|
+
name=name,
|
|
48
|
+
venv_backend=venv_backend,
|
|
49
|
+
venv_params=venv_params,
|
|
50
|
+
tags=tags,
|
|
51
|
+
default=default,
|
|
52
|
+
requires=requires,
|
|
53
|
+
uv_groups=uv_groups,
|
|
54
|
+
uv_extras=uv_extras,
|
|
55
|
+
uv_all_extras=uv_all_extras,
|
|
56
|
+
uv_all_groups=uv_all_groups,
|
|
57
|
+
) # type: ignore
|
|
58
|
+
|
|
59
|
+
[function] = args
|
|
60
|
+
|
|
61
|
+
is_uv = venv_backend == "uv"
|
|
62
|
+
|
|
63
|
+
# Create the `uv sync` command
|
|
64
|
+
sync_cmd = ["uv", "sync", "--no-default-groups"]
|
|
65
|
+
|
|
66
|
+
# Add the groups
|
|
67
|
+
for g in uv_groups:
|
|
68
|
+
sync_cmd.append(f"--group={g}")
|
|
69
|
+
|
|
70
|
+
# Add the extras
|
|
71
|
+
for e in uv_extras:
|
|
72
|
+
sync_cmd.append(f"--extra={e}")
|
|
73
|
+
|
|
74
|
+
if uv_all_groups:
|
|
75
|
+
sync_cmd.append("--all-groups")
|
|
76
|
+
|
|
77
|
+
if uv_all_extras:
|
|
78
|
+
sync_cmd.append("--all-extras")
|
|
79
|
+
|
|
80
|
+
@functools.wraps(function)
|
|
81
|
+
def wrapper(s: nox.Session, *_args: Any, **_kwargs: Any) -> None:
|
|
82
|
+
if is_uv:
|
|
83
|
+
env: dict[str, Any] = {"UV_PROJECT_ENVIRONMENT": s.virtualenv.location}
|
|
84
|
+
|
|
85
|
+
# UV called from Nox does not respect the Python version set in the Nox session.
|
|
86
|
+
# We need to pass the Python version to UV explicitly.
|
|
87
|
+
if s.python is not None:
|
|
88
|
+
env["UV_PYTHON"] = s.python
|
|
89
|
+
|
|
90
|
+
s.run_install(
|
|
91
|
+
*sync_cmd,
|
|
92
|
+
env=env,
|
|
93
|
+
)
|
|
94
|
+
function(nox.Session(s._runner), *_args, **_kwargs)
|
|
95
|
+
|
|
96
|
+
return nox.session( # type: ignore
|
|
97
|
+
wrapper,
|
|
98
|
+
python=python,
|
|
99
|
+
reuse_venv=reuse_venv,
|
|
100
|
+
name=name,
|
|
101
|
+
venv_backend=venv_backend,
|
|
102
|
+
venv_params=venv_params,
|
|
103
|
+
tags=tags,
|
|
104
|
+
default=default,
|
|
105
|
+
requires=requires,
|
|
106
|
+
)
|
nox_uv/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nox-uv
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Facilitate nox integration with uv for Python projects
|
|
5
|
+
Project-URL: Homepage, https://github.com/dantebben/nox-uv
|
|
6
|
+
Author-email: Dan Tebben <dantebben@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE.txt
|
|
9
|
+
Requires-Python: <3.14,>=3.9
|
|
10
|
+
Requires-Dist: nox>=2025.2.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
## Intro
|
|
14
|
+
|
|
15
|
+
This is heavliy influcenced by, but much more limited than,
|
|
16
|
+
[nox-poetry](https://nox-poetry.readthedocs.io).
|
|
17
|
+
|
|
18
|
+
This is a basic drop-in replacement for `nox.session` of [nox](https://nox.thea.codes/) to be used
|
|
19
|
+
with the [uv](https://docs.astral.sh/uv/) package manager.
|
|
20
|
+
|
|
21
|
+
To use, import `session` from `nox-uv` in your `nox-file`.
|
|
22
|
+
|
|
23
|
+
**NOTE**: All `@session(...)` parameters are keyword-only, no positional parameters are allowed.
|
|
24
|
+
|
|
25
|
+
**NOTE**: The `default_groups` defined in `pyproject.toml` are _not_ installed by default. The
|
|
26
|
+
user must explicitly list the desired groups in the `uv_groups` parameter.
|
|
27
|
+
|
|
28
|
+
## Added parameters
|
|
29
|
+
|
|
30
|
+
- `uv_groups`: list of `uv` dependency groups
|
|
31
|
+
- `uv_extras`: list of `uv` extras
|
|
32
|
+
- `uv_all_extras`: boolean to install all extras from `pyproject.toml`
|
|
33
|
+
- `uv_all_groups`: boolean to install all dependency groups
|
|
34
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
nox_uv/__init__.py,sha256=z--lgqfIK0Gct163ynH9As7uRbcYNimDWiRUzJ4nljQ,2961
|
|
2
|
+
nox_uv/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
nox_uv-0.1.0.dist-info/METADATA,sha256=cB7mMOq9UKdTh1yYgv0cvcwYYTQFADDKGE-ZF84b9ag,1214
|
|
4
|
+
nox_uv-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
+
nox_uv-0.1.0.dist-info/licenses/LICENSE.txt,sha256=iTZ5ALF1isnM6Ey9Tjom0XIGBBysArB0I2NHZ9a-b8I,1067
|
|
6
|
+
nox_uv-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dan Tebben
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|