Skip to content

Commit 28ca767

Browse files
committed
renderers: Guard against pyproject.project being null or empty
This is a requisite to add support for "legacy" packages using only setuptools but not pyproject.toml in uv2nix.
1 parent 3db43c7 commit 28ca767

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

build/lib/renderers.nix

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ in
4141
extras ? [ ],
4242
}:
4343
let
44-
inherit (project) pyproject;
45-
4644
filteredDeps = pep621.filterDependenciesByEnviron environ extras project.dependencies;
45+
project' = project.pyproject.project or { };
4746

4847
in
4948
{ pyprojectHook, resolveBuildSystem }:
@@ -62,22 +61,22 @@ in
6261
inherit project;
6362
};
6463
}
65-
// optionalAttrs (pyproject.project ? name) { pname = pyproject.project.name; }
66-
// optionalAttrs (pyproject.project ? version) { inherit (pyproject.project) version; }
67-
// optionalAttrs (!pyproject.project ? version && pyproject.project ? name) {
68-
inherit (pyproject.project) name;
64+
// optionalAttrs (project' ? name) { pname = project'.name; }
65+
// optionalAttrs (project' ? version) { inherit (project') version; }
66+
// optionalAttrs (!project' ? version && project' ? name) {
67+
inherit (project') name;
6968
}
70-
// optionalAttrs (project.projectRoot != null) { src = project.projectRoot; };
69+
// optionalAttrs ((project.projectRoot or null) != null) { src = project.projectRoot; };
7170

72-
/*
73-
Renders a project as an argument that can be passed to stdenv.mkDerivation.
71+
/*
72+
Renders a project as an argument that can be passed to stdenv.mkDerivation.
7473
75-
Evaluates PEP-508 environment markers to select correct dependencies for the platform but does not validate version constraints.
74+
Evaluates PEP-508 environment markers to select correct dependencies for the platform but does not validate version constraints.
7675
77-
Note: This API is unstable and subject to change.
76+
Note: This API is unstable and subject to change.
7877
79-
Type: mkDerivation :: AttrSet -> AttrSet
80-
*/
78+
Type: mkDerivation :: AttrSet -> AttrSet
79+
*/
8180
mkDerivationEditable =
8281
{
8382
# Loaded pyproject.nix project

lib/renderers.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ let
1717
inherit (lib)
1818
optionalAttrs
1919
mapAttrs'
20-
mapAttrs
2120
filterAttrs
2221
concatMap
2322
nameValuePair
@@ -272,7 +271,7 @@ in
272271
meta =
273272
{ project }:
274273
let
275-
project' = project.pyproject.project;
274+
project' = project.pyproject.project or { };
276275
urls = project'.urls or { };
277276
in
278277
# Optional changelog

0 commit comments

Comments
 (0)