Skip to content

Commit

Permalink
renderers: Guard against pyproject.project being null or empty
Browse files Browse the repository at this point in the history
This is a requisite to add support for "legacy" packages using only setuptools but not pyproject.toml in uv2nix.
  • Loading branch information
adisbladis committed Jan 24, 2025
1 parent 3db43c7 commit 28ca767
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
25 changes: 12 additions & 13 deletions build/lib/renderers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ in
extras ? [ ],
}:
let
inherit (project) pyproject;

filteredDeps = pep621.filterDependenciesByEnviron environ extras project.dependencies;
project' = project.pyproject.project or { };

in
{ pyprojectHook, resolveBuildSystem }:
Expand All @@ -62,22 +61,22 @@ in
inherit project;
};
}
// optionalAttrs (pyproject.project ? name) { pname = pyproject.project.name; }
// optionalAttrs (pyproject.project ? version) { inherit (pyproject.project) version; }
// optionalAttrs (!pyproject.project ? version && pyproject.project ? name) {
inherit (pyproject.project) name;
// optionalAttrs (project' ? name) { pname = project'.name; }
// optionalAttrs (project' ? version) { inherit (project') version; }
// optionalAttrs (!project' ? version && project' ? name) {
inherit (project') name;
}
// optionalAttrs (project.projectRoot != null) { src = project.projectRoot; };
// optionalAttrs ((project.projectRoot or null) != null) { src = project.projectRoot; };

/*
Renders a project as an argument that can be passed to stdenv.mkDerivation.
/*
Renders a project as an argument that can be passed to stdenv.mkDerivation.
Evaluates PEP-508 environment markers to select correct dependencies for the platform but does not validate version constraints.
Evaluates PEP-508 environment markers to select correct dependencies for the platform but does not validate version constraints.
Note: This API is unstable and subject to change.
Note: This API is unstable and subject to change.
Type: mkDerivation :: AttrSet -> AttrSet
*/
Type: mkDerivation :: AttrSet -> AttrSet
*/
mkDerivationEditable =
{
# Loaded pyproject.nix project
Expand Down
3 changes: 1 addition & 2 deletions lib/renderers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ let
inherit (lib)
optionalAttrs
mapAttrs'
mapAttrs
filterAttrs
concatMap
nameValuePair
Expand Down Expand Up @@ -272,7 +271,7 @@ in
meta =
{ project }:
let
project' = project.pyproject.project;
project' = project.pyproject.project or { };
urls = project'.urls or { };
in
# Optional changelog
Expand Down

0 comments on commit 28ca767

Please sign in to comment.