Skip to content

Commit

Permalink
build: Deprecate package set
Browse files Browse the repository at this point in the history
  • Loading branch information
adisbladis committed Nov 20, 2024
1 parent a4e838b commit f6f8e26
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 11 deletions.
20 changes: 14 additions & 6 deletions build/checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ let

python = pkgs.python312;

# Inject your own packages on top with overrideScope
pythonSet = pkgs.callPackage pyproject-nix.build.packages {
inherit python;
testOverlay = import ../test_overlay.nix {
inherit pyproject-nix lib;
};

# Inject your own packages on top with overrideScope
pythonSet =
(pkgs.callPackage pyproject-nix.build.packages {
inherit python;
}).overrideScope
testOverlay;

testVenv = pythonSet.pythonPkgsHostHost.mkVirtualEnv "test-venv" {
build = [ ];
};
Expand Down Expand Up @@ -43,9 +49,11 @@ in
let
pkgs' = pkgs.pkgsCross.aarch64-multiplatform;
python = pkgs'.python312;
crossSet = pkgs'.callPackage pyproject-nix.build.packages {
inherit python;
};
crossSet =
(pkgs'.callPackage pyproject-nix.build.packages {
inherit python;
}).overrideScope
testOverlay;
in
crossSet.pythonPkgsHostHost.mkVirtualEnv "cross-venv" {
build = [ ];
Expand Down
10 changes: 8 additions & 2 deletions build/hacks/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ let

python = pkgs.python3;

pythonSet = pkgs.callPackage pyproject-nix.build.packages {
inherit python;
testOverlay = import ../test_overlay.nix {
inherit pyproject-nix lib;
};

pythonSet =
(pkgs.callPackage pyproject-nix.build.packages {
inherit python;
}).overrideScope
testOverlay;

in
{
nixpkgsPrebuilt =
Expand Down
8 changes: 7 additions & 1 deletion build/lib/test_renderers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ let

python = pkgs.python312;

pythonSet = pkgs.callPackage pyproject-nix.build.packages { inherit python; };
testOverlay = import ../test_overlay.nix {
inherit pyproject-nix lib;
};

pythonSet =
(pkgs.callPackage pyproject-nix.build.packages { inherit python; }).overrideScope
testOverlay;

in

Expand Down
12 changes: 10 additions & 2 deletions build/packages.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
lib,
pyproject-nix,
resolvers,
pyproject-nix,
}:
let
inherit (resolvers) resolveCyclic resolveNonCyclic;
Expand Down Expand Up @@ -31,7 +31,15 @@ let

mkResolveVirtualEnv = set: spec: map (name: set.${name}) (resolveCyclic set spec);

pkgsFun = final: mkPkgs' { inherit (final) callPackage pyprojectBootstrapHook; };
deprecatedBuild = name: ''
You are using '${name}' from the pyproject.nix base package set.
This is deprecated in favour of https://github.com/pyproject-nix/build-system-pkgs and will be removed shortly.
'';
pkgsFun =
final:
lib.mapAttrs (name: drv: builtins.trace (deprecatedBuild name) drv) (mkPkgs' {
inherit (final) callPackage pyprojectBootstrapHook;
});

mkPythonSet =
{
Expand Down
54 changes: 54 additions & 0 deletions build/test_overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
lib,
pyproject-nix,
}:
let
overlay' =
final: _prev:
lib.mapAttrs
(
name: pkg:
if pyproject-nix.build.lib.isBootstrapPackage name then
final.callPackage pkg { pyprojectHook = final.pyprojectBootstrapHook; }
else
final.callPackage pkg { }
)
{
flit-core = ./pkgs/flit-core;
packaging = ./pkgs/packaging;
pyproject-hooks = ./pkgs/pyproject-hooks;
setuptools = ./pkgs/setuptools;
wheel = ./pkgs/wheel;
hatchling = ./pkgs/hatchling;
pdm-backend = ./pkgs/pdm-backend;
cython = ./pkgs/cython;
meson = ./pkgs/meson;
build = ./pkgs/build;
installer = ./pkgs/installer;
pathspec = ./pkgs/pathspec;
pluggy = ./pkgs/pluggy;
setuptools-scm = ./pkgs/setuptools-scm;
trove-classifiers = ./pkgs/trove-classifiers;
calver = ./pkgs/calver;
zipp = ./pkgs/zipp;
tomli-w = ./pkgs/tomli-w;
cffi = ./pkgs/cffi;
maturin = ./pkgs/maturin;
setuptools-rust = ./pkgs/setuptools-rust;
pycparser = ./pkgs/pycparser;
typing-extensions = ./pkgs/typing-extensions;
semantic-version = ./pkgs/semantic-version;
tomli = ./pkgs/tomli;
pip = ./pkgs/pip;
};

crossOverlay = lib.composeExtensions (_final: prev: {
pythonPkgsBuildHost = prev.pythonPkgsBuildHost.overrideScope overlay';
}) overlay';

in
final: prev:
if prev.stdenv.buildPlatform != prev.stdenv.hostPlatform then
crossOverlay final prev
else
overlay' final prev

0 comments on commit f6f8e26

Please sign in to comment.