Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6368496
python3.pkgs.bootstrap.flit-core: init at 3.8.0
tjni Jul 26, 2023
c14741f
python3.pkgs.bootstrap.installer: init at 0.7.0
tjni Jul 26, 2023
4bd44a0
python3.pkgs.bootstrap.build: init at 0.10.0
tjni Jul 26, 2023
80e182f
python3.pkgs.pypaInstallHook: init
tjni Jul 28, 2023
cf921ce
python3.pkgs.pypaBuildHook: switch to pyproject-build
tjni Jul 28, 2023
1534b37
python2.{buildPythonPackage,buildPythonApplication}: extract into its…
tjni Aug 2, 2023
6804ffe
python3.pkgs.buildPythonPackage: switch to PyPA build and installer
tjni Jul 28, 2023
418e03f
python3.pkgs.installer: move tests to passthru
tjni Jul 28, 2023
f283127
python3.pkgs.pyproject-hooks: move tests to passthru
tjni Jul 28, 2023
5a828fe
python3.pkgs.build: move tests to passthru
tjni Jul 28, 2023
2eaa076
python3.pkgs.buildPythonPackage: disable conflict check for setuptool…
tjni Jul 28, 2023
a2a26e8
python3.pkgs.pythonRelaxDepsHook: don't propagate wheel
tjni Aug 2, 2023
ed9764a
python3.pkgs.wheel: 0.38.4 -> 0.41.1
tjni Jul 28, 2023
095d213
poetry2nix.overrides.wheel: adapt to new wheel version
tjni Aug 2, 2023
c2c5dae
poetry2nix.overrides: update build systems for bootstrap packages
tjni Aug 2, 2023
7cc69f4
python3.pkgs.setuptools: build without bootstrapped-pip
tjni Jul 28, 2023
e166e25
python3.pkgs.pip: build without bootstrapped-pip
tjni Jul 28, 2023
dab872b
python3.pkgs.cypari2: build without bootstrapped-pip
tjni Jul 28, 2023
2d206c5
python3.pkgs.pip: 23.0.1 -> 23.2.1
tjni Jul 29, 2023
9bd5066
python3.pkgs.pip-tools: 6.13.0 -> 7.2.0
tjni Jul 31, 2023
567e7a1
python3.pkgs.setuptools: 67.4.0 -> 68.0.0
tjni Jul 29, 2023
3dbdd8b
python3.pkgs.pip: install shell completions
tjni Aug 12, 2023
d3d0b28
python3.pkgs.pyproject-api: 1.5.0 -> 1.5.4
tjni Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions pkgs/development/interpreters/python/hooks/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
self: dontUse: with self;

let
pythonInterpreter = python.pythonForBuild.interpreter;
inherit (python) pythonForBuild;
pythonInterpreter = pythonForBuild.interpreter;
pythonSitePackages = python.sitePackages;
pythonCheckInterpreter = python.interpreter;
setuppy = ../run_setup.py;
Expand Down Expand Up @@ -66,11 +67,9 @@ in {
makePythonHook {
name = "pypa-build-hook.sh";
propagatedBuildInputs = [ build wheel ];
substitutions = {
inherit pythonInterpreter;
};
} ./pypa-build-hook.sh) {};

} ./pypa-build-hook.sh) {
inherit (pythonForBuild.pkgs) build;
};

pipInstallHook = callPackage ({ makePythonHook, pip }:
makePythonHook {
Expand All @@ -81,6 +80,17 @@ in {
};
} ./pip-install-hook.sh) {};

pypaInstallHook = callPackage ({ makePythonHook, installer }:
makePythonHook {
name = "pypa-install-hook";
propagatedBuildInputs = [ installer ];
substitutions = {
inherit pythonInterpreter pythonSitePackages;
};
} ./pypa-install-hook.sh) {
inherit (pythonForBuild.pkgs) installer;
};

pytestCheckHook = callPackage ({ makePythonHook, pytest }:
makePythonHook {
name = "pytest-check-hook";
Expand Down Expand Up @@ -133,9 +143,8 @@ in {
pythonRelaxDepsHook = callPackage ({ makePythonHook, wheel }:
makePythonHook {
name = "python-relax-deps-hook";
propagatedBuildInputs = [ wheel ];
substitutions = {
inherit pythonInterpreter;
inherit pythonInterpreter pythonSitePackages wheel;
};
} ./python-relax-deps-hook.sh) {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pypaBuildPhase() {
runHook preBuild

echo "Creating a wheel..."
@pythonInterpreter@ -m build --no-isolation --outdir dist/ --wheel $pypaBuildFlags
pyproject-build --no-isolation --outdir dist/ --wheel $pypaBuildFlags
echo "Finished creating a wheel..."

runHook postBuild
Expand Down
21 changes: 21 additions & 0 deletions pkgs/development/interpreters/python/hooks/pypa-install-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Setup hook for PyPA installer.
echo "Sourcing pypa-install-hook"

pypaInstallPhase() {
echo "Executing pypaInstallPhase"
runHook preInstall

for wheel in dist/*.whl; do
@pythonInterpreter@ -m installer --prefix "$out" "$wheel"
done

export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH"

runHook postInstall
echo "Finished executing pypaInstallPhase"
}

if [ -z "${dontUsePypaInstall-}" ] && [ -z "${installPhase-}" ]; then
echo "Using pypaInstallPhase"
installPhase=pypaInstallPhase
fi
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ pythonRelaxDepsHook() {

# We generally shouldn't have multiple wheel files, but let's be safer here
for wheel in "$pkg_name"*".whl"; do
@pythonInterpreter@ -m wheel unpack --dest "$unpack_dir" "$wheel"
PYTHONPATH="@wheel@/@pythonSitePackages@:$PYTHONPATH" \
@pythonInterpreter@ -m wheel unpack --dest "$unpack_dir" "$wheel"
rm -rf "$wheel"

_pythonRelaxDeps "$metadata_file"
Expand All @@ -95,7 +96,8 @@ pythonRelaxDepsHook() {
cat "$unpack_dir/$pkg_name/$pkg_name.dist-info/METADATA"
fi

@pythonInterpreter@ -m wheel pack "$unpack_dir/$pkg_name"
PYTHONPATH="@wheel@/@pythonSitePackages@:$PYTHONPATH" \
@pythonInterpreter@ -m wheel pack "$unpack_dir/$pkg_name"
done

# Remove the folder since it will otherwise be in the dist output.
Expand Down
51 changes: 42 additions & 9 deletions pkgs/development/interpreters/python/mk-python-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
, update-python-libraries
, setuptools
, flitBuildHook
, pipBuildHook
, pipInstallHook
, pypaBuildHook
, pypaInstallHook
, pythonCatchConflictsHook
, pythonImportsCheckHook
, pythonNamespacesHook
Expand Down Expand Up @@ -161,6 +161,20 @@ let

in inputs: builtins.map (checkDrv) inputs;

isBootstrapInstallPackage = builtins.elem (attrs.pname or null) [
"flit-core" "installer"
];

isBootstrapPackage = isBootstrapInstallPackage || builtins.elem (attrs.pname or null) ([
"build" "packaging" "pyproject-hooks" "wheel"
] ++ lib.optionals (python.pythonOlder "3.11") [
"tomli"
]);

isSetuptoolsDependency = builtins.elem (attrs.pname or null) [
"setuptools" "wheel"
];

# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [
"disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "format"
Expand All @@ -174,7 +188,15 @@ let
wrapPython
ensureNewerSourcesForZipFilesHook # move to wheel installer (pip) or builder (setuptools, flit, ...)?
pythonRemoveTestsDirHook
] ++ lib.optionals catchConflicts [
] ++ lib.optionals (catchConflicts && !isBootstrapPackage && !isSetuptoolsDependency) [
#
# 1. When building a package that is also part of the bootstrap chain, we
# must ignore conflicts after installation, because there will be one with
# the package in the bootstrap.
#
# 2. When a package is a dependency of setuptools, we must ignore conflicts
# because the hook that checks for conflicts uses setuptools.
#
pythonCatchConflictsHook
] ++ lib.optionals removeBinBytecode [
pythonRemoveBinBytecodeHook
Expand All @@ -184,15 +206,26 @@ let
setuptoolsBuildHook
] ++ lib.optionals (format == "flit") [
flitBuildHook
] ++ lib.optionals (format == "pyproject") [
pipBuildHook
] ++ lib.optionals (format == "wheel") [
] ++ lib.optionals (format == "pyproject") [(
if isBootstrapPackage then
pypaBuildHook.override {
inherit (python.pythonForBuild.pkgs.bootstrap) build;
wheel = null;
}
else
pypaBuildHook
)] ++ lib.optionals (format == "wheel") [
wheelUnpackHook
] ++ lib.optionals (format == "egg") [
eggUnpackHook eggBuildHook eggInstallHook
] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [
pipInstallHook
] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
] ++ lib.optionals (format != "other") [(
if isBootstrapInstallPackage then
pypaInstallHook.override {
inherit (python.pythonForBuild.pkgs.bootstrap) installer;
}
else
pypaInstallHook
)] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
# This is a test, however, it should be ran independent of the checkPhase and checkInputs
pythonImportsCheckHook
] ++ lib.optionals (python.pythonAtLeast "3.3") [
Expand Down
9 changes: 7 additions & 2 deletions pkgs/development/interpreters/python/python-packages-base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ let
}
else result;

buildPythonPackage = makeOverridablePythonPackage (lib.makeOverridable (callPackage ./mk-python-derivation.nix {
mkPythonDerivation = if python.isPy3k then
./mk-python-derivation.nix
else
./python2/mk-python-derivation.nix;

buildPythonPackage = makeOverridablePythonPackage (lib.makeOverridable (callPackage mkPythonDerivation {
inherit namePrefix; # We want Python libraries to be named like e.g. "python3.6-${name}"
inherit toPythonModule; # Libraries provide modules
}));

buildPythonApplication = makeOverridablePythonPackage (lib.makeOverridable (callPackage ./mk-python-derivation.nix {
buildPythonApplication = makeOverridablePythonPackage (lib.makeOverridable (callPackage mkPythonDerivation {
namePrefix = ""; # Python applications should not have any prefix
toPythonModule = x: x; # Application does not provide modules.
}));
Expand Down
Loading