Skip to content

Commit 2caa46d

Browse files
committed
Add PEP-735 dependency groups
This introduces a breaking change. Previously `dev-dependencies` were remapped as optional dependencies, still named `dev-dependencies`: ``` nix virtualenv = editablePythonSet.mkVirtualEnv "hello-world-dev-env" { hello-world = [ "dev-dependencies" ]; }; ``` Will now be written simply as `dev`, refering to a dependency group, and not an optional feature: ``` nix virtualenv = editablePythonSet.mkVirtualEnv "hello-world-dev-env" { hello-world = [ "dev" ]; }; ``` This mirrors new Uv behaviour introduced in astral-sh/uv#8272. See pyproject-nix/pyproject.nix#170 for pyproject.nix changes.
1 parent 07711a7 commit 2caa46d

File tree

8 files changed

+97
-27
lines changed

8 files changed

+97
-27
lines changed

dev/checks.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ let
6868
ws = uv2nix.workspace.loadWorkspace { workspaceRoot = root; };
6969

7070
# Build Python environment based on builder implementation
71-
pythonEnv = let
71+
pythonEnv = (
72+
let
7273
# Generate overlay
7374
overlay = ws.mkPyprojectOverlay { inherit sourcePreference environ; };
7475

@@ -81,7 +82,8 @@ let
8182

8283
in
8384
# Render venv
84-
pythonSet.pythonPkgsHostHost.mkVirtualEnv "test-venv" spec;
85+
pythonSet.pythonPkgsHostHost.mkVirtualEnv "test-venv" spec
86+
);
8587

8688
in
8789
if check != null then

flake.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
nix-github-actions.url = "github:nix-community/nix-github-actions";
1111
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
1212

13-
pyproject-nix.url = "github:nix-community/pyproject.nix";
13+
pyproject-nix.url = "github:nix-community/pyproject.nix/pep735";
1414
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
1515
pyproject-nix.inputs.nix-github-actions.follows = "nix-github-actions";
1616
pyproject-nix.inputs.mdbook-nixdoc.follows = "mdbook-nixdoc";

lib/build.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ in
100100
passthru = {
101101
dependencies = mkSpec package.dependencies;
102102
optional-dependencies = mapAttrs (_: mkSpec) package.optional-dependencies;
103+
dependency-groups = mapAttrs (_: mkSpec) package.dev-dependencies;
103104
inherit format;
104105
};
105106

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[project]
2+
name = "dependency-groups"
3+
version = "0.1.0"
4+
description = "Testing dependency groups"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = []
8+
9+
# Dependency groups are rendered in uv.lock as package.dev-dependencies
10+
[dependency-groups]
11+
group-a = ["urllib3"]
12+
13+
# Special older syntax for dependency groups
14+
# tool.uv.dev-dependencies are rendered in lock file as:
15+
#
16+
# [package.dev-dependencies]
17+
# dev = [
18+
# { name = "arpeggio" },
19+
# ]
20+
[tool.uv]
21+
dev-dependencies = [
22+
"arpeggio"
23+
]
24+
25+
[build-system]
26+
requires = ["hatchling"]
27+
build-backend = "hatchling.build"

lib/fixtures/dependency-groups/uv.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/hello-world/flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114

115115
# Build virtual environment
116116
virtualenv = editablePythonSet.mkVirtualEnv "hello-world-dev-env" {
117-
# Add hello world with it's dev dependencies
118-
hello-world = [ "dev-dependencies" ];
117+
# Add hello world with it's dev dependency group
118+
hello-world = [ "dev" ];
119119
};
120120

121121
in

templates/hello-world/uv.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)