Skip to content

Commit

Permalink
Merge pull request #1785 from Lykos153/feature/default-deps-main-group
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Oct 28, 2024
2 parents 5cc8e8e + 61889c3 commit caddf14
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let
, pyProject
, attrs
, includeBuildSystem ? true
, groups ? [ ]
, groups ? [ "main" ]
, checkGroups ? checkGroupsDefault
, extras ? [ "*" ] # * means all extras, otherwise include the dependencies for a given extra
}:
Expand Down Expand Up @@ -82,12 +82,10 @@ let
{
buildInputs = mkInput "buildInputs" (if includeBuildSystem then buildSystemPkgs else [ ]);
propagatedBuildInputs = mkInput "propagatedBuildInputs" (
getDeps allRawDeps ++ (
# >=poetry-1.2.0 dependency groups
if pyProject.tool.poetry.group or { } != { }
then lib.flatten (map (g: getDeps pyProject.tool.poetry.group.${g}.dependencies) groups)
else [ ]
)
let
availableGroups = { main.dependencies = allRawDeps; } // pyProject.tool.poetry.group or { };
in
lib.flatten (map (g: getDeps availableGroups.${g}.dependencies or { }) groups)
);
nativeBuildInputs = mkInput "nativeBuildInputs" [ ];
checkInputs = mkInput "checkInputs" checkInputs';
Expand Down Expand Up @@ -145,7 +143,7 @@ lib.makeScope pkgs.newScope (self: {
# Example: { my-app = ./src; }
, editablePackageSources ? { }
, pyProject ? readTOML pyproject
, groups ? [ ]
, groups ? [ "main" ]
, checkGroups ? checkGroupsDefault
, extras ? [ "*" ]
}:
Expand Down Expand Up @@ -314,7 +312,7 @@ lib.makeScope pkgs.newScope (self: {
, preferWheels ? false
, editablePackageSources ? { }
, extraPackages ? _ps: [ ]
, groups ? [ "dev" ]
, groups ? [ "main" "dev" ]
, checkGroups ? checkGroupsDefault
, extras ? [ "*" ]
}:
Expand All @@ -332,13 +330,13 @@ lib.makeScope pkgs.newScope (self: {
(pkg: editablePackageSources."${pkg}" == null)
(builtins.attrNames editablePackageSources);

allEditablePackageSources = (getEditableDeps (pyProject.tool.poetry."dependencies" or { }))
// (getEditableDeps (pyProject.tool.poetry."dev-dependencies" or { }))
allEditablePackageSources = (getEditableDeps (pyProject.tool.poetry."dev-dependencies" or { }))
// (
# Poetry>=1.2.0
if pyProject.tool.poetry.group or { } != { } then
builtins.foldl' (acc: g: acc // getEditableDeps pyProject.tool.poetry.group.${g}.dependencies) { } groups
else { }
let
deps = pyProject.tool.poetry."dependencies" or { };
availableGroups = { main.dependencies = deps; } // pyProject.tool.poetry.group or { };
in
builtins.foldl' (acc: g: acc // getEditableDeps availableGroups.${g}.dependencies or { }) { } groups
)
// editablePackageSources;

Expand Down Expand Up @@ -380,7 +378,7 @@ lib.makeScope pkgs.newScope (self: {
, python ? pkgs.python3
, pwd ? projectDir
, preferWheels ? false
, groups ? [ ]
, groups ? [ "main" ]
, checkGroups ? checkGroupsDefault
, extras ? [ "*" ]
, ...
Expand Down

0 comments on commit caddf14

Please sign in to comment.