pythonPackages: ensure all derivations provide python modules

This adds a test to ensure no new uses of `buildPythonApplication` can
be added to `python-packages.nix`.

Python packages can be grouped into two groups: 1) applications and 2)
packages providing importable modules. In `python-packages.nix` we only
want to have 2). 1) should be in the top-level package set.

To achieve this, all setup hooks need to be marked as being a setup hook.
For the setup hooks in the Python packages set this is done by creating
a new builder, `makePythonHook`.

Because there were issues with splicing, the file importing all the hooks
is converted to an extension. All non-packages were moved out of `python-packages.nix`
into `python-packages-base.nix`. The `keep` argument to `makeScopeWithSplicing
was cleaned up as well; there is no need to keep this one manually in sync
reducing the risk of breaking cross-compilation.
This commit is contained in:
Frederik Rietdijk 2022-10-03 12:25:02 +02:00 committed by Frederik Rietdijk
parent 99bcead8dd
commit 33d12e5f0b
6 changed files with 185 additions and 242 deletions

View File

@ -31,13 +31,19 @@
, pythonAttr ? null , pythonAttr ? null
, self # is pythonOnHostForTarget , self # is pythonOnHostForTarget
}: let }: let
pythonPackages = callPackage pythonPackages = let
ensurePythonModules = items: let
providesSetupHook = lib.attrByPath [ "provides" "setupHook"] false;
notValid = value: (lib.isDerivation value) && !((pythonPackages.hasPythonModule value) || (providesSetupHook value));
func = name: value: if !(notValid value) then value else throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set.";
in lib.mapAttrs func items;
in ensurePythonModules (callPackage
# Function that when called # Function that when called
# - imports python-packages.nix # - imports python-packages.nix
# - adds spliced package sets to the package set # - adds spliced package sets to the package set
# - applies overrides from `packageOverrides` and `pythonPackagesOverlays`. # - applies overrides from `packageOverrides` and `pythonPackagesOverlays`.
({ pkgs, stdenv, python, overrides }: let ({ pkgs, stdenv, python, overrides }: let
pythonPackagesFun = import ../../../top-level/python-packages.nix { pythonPackagesFun = import ./python-packages-base.nix {
inherit stdenv pkgs lib; inherit stdenv pkgs lib;
python = self; python = self;
}; };
@ -48,47 +54,19 @@
selfHostHost = pythonOnHostForHost.pkgs; selfHostHost = pythonOnHostForHost.pkgs;
selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget. selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget.
}; };
keep = self: { hooks = import ./hooks/default.nix;
# TODO maybe only define these here so nothing is needed to be kept in sync. keep = lib.extends hooks pythonPackagesFun;
inherit (self)
isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy3k isPyPy pythonAtLeast pythonOlder
python bootstrapped-pip buildPythonPackage buildPythonApplication
fetchPypi
hasPythonModule requiredPythonModules makePythonPath disabledIf
toPythonModule toPythonApplication
buildSetupcfg
condaInstallHook
condaUnpackHook
eggUnpackHook
eggBuildHook
eggInstallHook
flitBuildHook
pipBuildHook
pipInstallHook
pytestCheckHook
pythonCatchConflictsHook
pythonImportsCheckHook
pythonNamespacesHook
pythonRecompileBytecodeHook
pythonRemoveBinBytecodeHook
pythonRemoveTestsDirHook
setuptoolsBuildHook
setuptoolsCheckHook
venvShellHook
wheelUnpackHook
wrapPython
pythonPackages
recursivePthLoader
;
};
extra = _: {}; extra = _: {};
optionalExtensions = cond: as: if cond then as else []; optionalExtensions = cond: as: if cond then as else [];
pythonExtension = import ../../../top-level/python-packages.nix;
python2Extension = import ../../../top-level/python2-packages.nix; python2Extension = import ../../../top-level/python2-packages.nix;
extensions = lib.composeManyExtensions ((optionalExtensions (!self.isPy3k) [python2Extension]) ++ pythonPackagesExtensions ++ [ overrides ]); extensions = lib.composeManyExtensions ([
pythonExtension
] ++ (optionalExtensions (!self.isPy3k) [
python2Extension
]) ++ pythonPackagesExtensions ++ [
overrides
]);
aliases = self: super: lib.optionalAttrs config.allowAliases (import ../../../top-level/python-aliases.nix lib self super); aliases = self: super: lib.optionalAttrs config.allowAliases (import ../../../top-level/python-aliases.nix lib self super);
in lib.makeScopeWithSplicing in lib.makeScopeWithSplicing
splicePackages splicePackages
@ -96,11 +74,11 @@
otherSplices otherSplices
keep keep
extra extra
(lib.extends (lib.composeExtensions aliases extensions) pythonPackagesFun)) (lib.extends (lib.composeExtensions aliases extensions) keep))
{ {
overrides = packageOverrides; overrides = packageOverrides;
python = self; python = self;
}; });
in rec { in rec {
isPy27 = pythonVersion == "2.7"; isPy27 = pythonVersion == "2.7";
isPy35 = pythonVersion == "3.5"; isPy35 = pythonVersion == "3.5";

View File

@ -1,21 +1,15 @@
# Hooks for building Python packages. self: super: with self;
{ python
, lib
, makeSetupHook
, disabledIf
, isPy3k
}:
let let
callPackage = python.pythonForBuild.pkgs.callPackage; pythonInterpreter = super.python.pythonForBuild.interpreter;
pythonInterpreter = python.pythonForBuild.interpreter; pythonSitePackages = super.python.sitePackages;
pythonSitePackages = python.sitePackages; pythonCheckInterpreter = super.python.interpreter;
pythonCheckInterpreter = python.interpreter;
setuppy = ../run_setup.py; setuppy = ../run_setup.py;
in rec { in {
makePythonHook = args: pkgs.makeSetupHook ({passthru.provides.setupHook = true; } // args);
condaInstallHook = callPackage ({ gnutar, lbzip2 }: condaInstallHook = callPackage ({ makePythonHook, gnutar, lbzip2 }:
makeSetupHook { makePythonHook {
name = "conda-install-hook"; name = "conda-install-hook";
deps = [ gnutar lbzip2 ]; deps = [ gnutar lbzip2 ];
substitutions = { substitutions = {
@ -23,20 +17,20 @@ in rec {
}; };
} ./conda-install-hook.sh) {}; } ./conda-install-hook.sh) {};
condaUnpackHook = callPackage ({}: condaUnpackHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "conda-unpack-hook"; name = "conda-unpack-hook";
deps = []; deps = [];
} ./conda-unpack-hook.sh) {}; } ./conda-unpack-hook.sh) {};
eggBuildHook = callPackage ({ }: eggBuildHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "egg-build-hook.sh"; name = "egg-build-hook.sh";
deps = [ ]; deps = [ ];
} ./egg-build-hook.sh) {}; } ./egg-build-hook.sh) {};
eggInstallHook = callPackage ({ setuptools }: eggInstallHook = callPackage ({ makePythonHook, setuptools }:
makeSetupHook { makePythonHook {
name = "egg-install-hook.sh"; name = "egg-install-hook.sh";
deps = [ setuptools ]; deps = [ setuptools ];
substitutions = { substitutions = {
@ -44,14 +38,14 @@ in rec {
}; };
} ./egg-install-hook.sh) {}; } ./egg-install-hook.sh) {};
eggUnpackHook = callPackage ({ }: eggUnpackHook = callPackage ({ makePythonHook, }:
makeSetupHook { makePythonHook {
name = "egg-unpack-hook.sh"; name = "egg-unpack-hook.sh";
deps = [ ]; deps = [ ];
} ./egg-unpack-hook.sh) {}; } ./egg-unpack-hook.sh) {};
flitBuildHook = callPackage ({ flit }: flitBuildHook = callPackage ({ makePythonHook, flit }:
makeSetupHook { makePythonHook {
name = "flit-build-hook"; name = "flit-build-hook";
deps = [ flit ]; deps = [ flit ];
substitutions = { substitutions = {
@ -59,8 +53,8 @@ in rec {
}; };
} ./flit-build-hook.sh) {}; } ./flit-build-hook.sh) {};
pipBuildHook = callPackage ({ pip, wheel }: pipBuildHook = callPackage ({ makePythonHook, pip, wheel }:
makeSetupHook { makePythonHook {
name = "pip-build-hook.sh"; name = "pip-build-hook.sh";
deps = [ pip wheel ]; deps = [ pip wheel ];
substitutions = { substitutions = {
@ -68,8 +62,8 @@ in rec {
}; };
} ./pip-build-hook.sh) {}; } ./pip-build-hook.sh) {};
pipInstallHook = callPackage ({ pip }: pipInstallHook = callPackage ({ makePythonHook, pip }:
makeSetupHook { makePythonHook {
name = "pip-install-hook"; name = "pip-install-hook";
deps = [ pip ]; deps = [ pip ];
substitutions = { substitutions = {
@ -77,8 +71,8 @@ in rec {
}; };
} ./pip-install-hook.sh) {}; } ./pip-install-hook.sh) {};
pytestCheckHook = callPackage ({ pytest }: pytestCheckHook = callPackage ({ makePythonHook, pytest }:
makeSetupHook { makePythonHook {
name = "pytest-check-hook"; name = "pytest-check-hook";
deps = [ pytest ]; deps = [ pytest ];
substitutions = { substitutions = {
@ -86,8 +80,8 @@ in rec {
}; };
} ./pytest-check-hook.sh) {}; } ./pytest-check-hook.sh) {};
pythonCatchConflictsHook = callPackage ({ setuptools }: pythonCatchConflictsHook = callPackage ({ makePythonHook, setuptools }:
makeSetupHook { makePythonHook {
name = "python-catch-conflicts-hook"; name = "python-catch-conflicts-hook";
substitutions = { substitutions = {
inherit pythonInterpreter pythonSitePackages setuptools; inherit pythonInterpreter pythonSitePackages setuptools;
@ -95,29 +89,29 @@ in rec {
}; };
} ./python-catch-conflicts-hook.sh) {}; } ./python-catch-conflicts-hook.sh) {};
pythonImportsCheckHook = callPackage ({}: pythonImportsCheckHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "python-imports-check-hook.sh"; name = "python-imports-check-hook.sh";
substitutions = { substitutions = {
inherit pythonCheckInterpreter; inherit pythonCheckInterpreter;
}; };
} ./python-imports-check-hook.sh) {}; } ./python-imports-check-hook.sh) {};
pythonNamespacesHook = callPackage ({ findutils }: pythonNamespacesHook = callPackage ({ makePythonHook, findutils }:
makeSetupHook { makePythonHook {
name = "python-namespaces-hook.sh"; name = "python-namespaces-hook.sh";
substitutions = { substitutions = {
inherit pythonSitePackages findutils; inherit pythonSitePackages findutils;
}; };
} ./python-namespaces-hook.sh) {}; } ./python-namespaces-hook.sh) {};
pythonOutputDistHook = callPackage ({ }: pythonOutputDistHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "python-output-dist-hook"; name = "python-output-dist-hook";
} ./python-output-dist-hook.sh ) {}; } ./python-output-dist-hook.sh ) {};
pythonRecompileBytecodeHook = callPackage ({ }: pythonRecompileBytecodeHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "python-recompile-bytecode-hook"; name = "python-recompile-bytecode-hook";
substitutions = { substitutions = {
inherit pythonInterpreter pythonSitePackages; inherit pythonInterpreter pythonSitePackages;
@ -126,8 +120,8 @@ in rec {
}; };
} ./python-recompile-bytecode-hook.sh ) {}; } ./python-recompile-bytecode-hook.sh ) {};
pythonRelaxDepsHook = callPackage ({ wheel }: pythonRelaxDepsHook = callPackage ({ makePythonHook, wheel }:
makeSetupHook { makePythonHook {
name = "python-relax-deps-hook"; name = "python-relax-deps-hook";
deps = [ wheel ]; deps = [ wheel ];
substitutions = { substitutions = {
@ -135,21 +129,21 @@ in rec {
}; };
} ./python-relax-deps-hook.sh) {}; } ./python-relax-deps-hook.sh) {};
pythonRemoveBinBytecodeHook = callPackage ({ }: pythonRemoveBinBytecodeHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "python-remove-bin-bytecode-hook"; name = "python-remove-bin-bytecode-hook";
} ./python-remove-bin-bytecode-hook.sh) {}; } ./python-remove-bin-bytecode-hook.sh) {};
pythonRemoveTestsDirHook = callPackage ({ }: pythonRemoveTestsDirHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "python-remove-tests-dir-hook"; name = "python-remove-tests-dir-hook";
substitutions = { substitutions = {
inherit pythonSitePackages; inherit pythonSitePackages;
}; };
} ./python-remove-tests-dir-hook.sh) {}; } ./python-remove-tests-dir-hook.sh) {};
setuptoolsBuildHook = callPackage ({ setuptools, wheel }: setuptoolsBuildHook = callPackage ({ makePythonHook, setuptools, wheel }:
makeSetupHook { makePythonHook {
name = "setuptools-setup-hook"; name = "setuptools-setup-hook";
deps = [ setuptools wheel ]; deps = [ setuptools wheel ];
substitutions = { substitutions = {
@ -157,8 +151,8 @@ in rec {
}; };
} ./setuptools-build-hook.sh) {}; } ./setuptools-build-hook.sh) {};
setuptoolsCheckHook = callPackage ({ setuptools }: setuptoolsCheckHook = callPackage ({ makePythonHook, setuptools }:
makeSetupHook { makePythonHook {
name = "setuptools-check-hook"; name = "setuptools-check-hook";
deps = [ setuptools ]; deps = [ setuptools ];
substitutions = { substitutions = {
@ -166,16 +160,16 @@ in rec {
}; };
} ./setuptools-check-hook.sh) {}; } ./setuptools-check-hook.sh) {};
unittestCheckHook = callPackage ({ }: unittestCheckHook = callPackage ({ makePythonHook }:
makeSetupHook { makePythonHook {
name = "unittest-check-hook"; name = "unittest-check-hook";
substitutions = { substitutions = {
inherit pythonCheckInterpreter; inherit pythonCheckInterpreter;
}; };
} ./unittest-check-hook.sh) {}; } ./unittest-check-hook.sh) {};
venvShellHook = disabledIf (!isPy3k) (callPackage ({ ensureNewerSourcesForZipFilesHook }: venvShellHook = disabledIf (!isPy3k) (callPackage ({ makePythonHook, ensureNewerSourcesForZipFilesHook }:
makeSetupHook { makePythonHook {
name = "venv-shell-hook"; name = "venv-shell-hook";
deps = [ ensureNewerSourcesForZipFilesHook ]; deps = [ ensureNewerSourcesForZipFilesHook ];
substitutions = { substitutions = {
@ -183,14 +177,18 @@ in rec {
}; };
} ./venv-shell-hook.sh) {}); } ./venv-shell-hook.sh) {});
wheelUnpackHook = callPackage ({ wheel }: wheelUnpackHook = callPackage ({ makePythonHook, wheel }:
makeSetupHook { makePythonHook {
name = "wheel-unpack-hook.sh"; name = "wheel-unpack-hook.sh";
deps = [ wheel ]; deps = [ wheel ];
} ./wheel-unpack-hook.sh) {}; } ./wheel-unpack-hook.sh) {};
sphinxHook = callPackage ({ sphinx, installShellFiles }: wrapPython = callPackage ../wrap-python.nix {
makeSetupHook { inherit (pkgs.buildPackages) makeWrapper;
};
sphinxHook = callPackage ({ makePythonHook, sphinx, installShellFiles }:
makePythonHook {
name = "python${python.pythonVersion}-sphinx-hook"; name = "python${python.pythonVersion}-sphinx-hook";
deps = [ sphinx installShellFiles ]; deps = [ sphinx installShellFiles ];
} ./sphinx-hook.sh) {}; } ./sphinx-hook.sh) {};

View File

@ -0,0 +1,104 @@
{ pkgs
, stdenv
, lib
, python
}:
self:
let
inherit (self) callPackage;
inherit (python.passthru) isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy311 isPy3k isPyPy pythonAtLeast pythonOlder;
namePrefix = python.libPrefix + "-";
# Derivations built with `buildPythonPackage` can already be overriden with `override`, `overrideAttrs`, and `overrideDerivation`.
# This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`.
makeOverridablePythonPackage = f: origArgs:
let
ff = f origArgs;
overrideWith = newArgs: origArgs // (if pkgs.lib.isFunction newArgs then newArgs origArgs else newArgs);
in
if builtins.isAttrs ff then (ff // {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
})
else if builtins.isFunction ff then {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
__functor = self: ff;
}
else ff;
buildPythonPackage = makeOverridablePythonPackage (lib.makeOverridable (callPackage ./mk-python-derivation.nix {
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 {
namePrefix = ""; # Python applications should not have any prefix
toPythonModule = x: x; # Application does not provide modules.
}));
# See build-setupcfg/default.nix for documentation.
buildSetupcfg = import ../../../build-support/build-setupcfg self;
fetchPypi = callPackage ./fetchpypi.nix { };
# Check whether a derivation provides a Python module.
hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
# Get list of required Python modules given a list of derivations.
requiredPythonModules = drvs: let
modules = lib.filter hasPythonModule drvs;
in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
# Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations
# providing Python modules.
makePythonPath = drvs: lib.makeSearchPath python.sitePackages (requiredPythonModules drvs);
removePythonPrefix = lib.removePrefix namePrefix;
# Convert derivation to a Python module.
toPythonModule = drv:
drv.overrideAttrs( oldAttrs: {
# Use passthru in order to prevent rebuilds when possible.
passthru = (oldAttrs.passthru or {})// {
pythonModule = python;
pythonPath = [ ]; # Deprecated, for compatibility.
requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
};
});
# Convert a Python library to an application.
toPythonApplication = drv:
drv.overrideAttrs( oldAttrs: {
passthru = (oldAttrs.passthru or {}) // {
# Remove Python prefix from name so we have a "normal" name.
# While the prefix shows up in the store path, it won't be
# used by `nix-env`.
name = removePythonPrefix oldAttrs.name;
pythonModule = false;
};
});
disabled = drv: throw "${removePythonPrefix (drv.pname or drv.name)} not supported for interpreter ${python.executable}";
disabledIf = x: drv: if x then disabled drv else drv;
in {
inherit lib pkgs stdenv;
inherit (python.passthru) isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy311 isPy3k isPyPy pythonAtLeast pythonOlder;
inherit buildPythonPackage buildPythonApplication;
inherit fetchPypi;
inherit hasPythonModule requiredPythonModules makePythonPath disabled disabledIf;
inherit toPythonModule toPythonApplication;
inherit buildSetupcfg;
python = toPythonModule python;
# Dont take pythonPackages from "global" pkgs scope to avoid mixing python versions
pythonPackages = self;
# Remove?
recursivePthLoader = toPythonModule (callPackage ../../../development/python-modules/recursive-pth-loader { });
}

View File

@ -1,11 +1,11 @@
{ lib { lib
, python , python
, makeSetupHook , makePythonHook
, makeWrapper }: , makeWrapper }:
with lib; with lib;
makeSetupHook { makePythonHook {
deps = makeWrapper; deps = makeWrapper;
substitutions.sitePackages = python.sitePackages; substitutions.sitePackages = python.sitePackages;
substitutions.executable = python.interpreter; substitutions.executable = python.interpreter;

View File

@ -6,146 +6,9 @@
# #
# For more details, please see the Python section in the Nixpkgs manual. # For more details, please see the Python section in the Nixpkgs manual.
{ pkgs self: super: with self; {
, stdenv
, lib
, python
}:
self: bootstrapped-pip = toPythonModule (callPackage ../development/python-modules/bootstrapped-pip { });
let
inherit (self) callPackage;
inherit (python.passthru) isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy311 isPy3k isPyPy pythonAtLeast pythonOlder;
namePrefix = python.libPrefix + "-";
bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { };
# Derivations built with `buildPythonPackage` can already be overriden with `override`, `overrideAttrs`, and `overrideDerivation`.
# This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`.
makeOverridablePythonPackage = f: origArgs:
let
ff = f origArgs;
overrideWith = newArgs: origArgs // (if pkgs.lib.isFunction newArgs then newArgs origArgs else newArgs);
in
if builtins.isAttrs ff then (ff // {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
})
else if builtins.isFunction ff then {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
__functor = self: ff;
}
else ff;
buildPythonPackage = makeOverridablePythonPackage (lib.makeOverridable (callPackage ../development/interpreters/python/mk-python-derivation.nix {
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 ../development/interpreters/python/mk-python-derivation.nix {
namePrefix = ""; # Python applications should not have any prefix
toPythonModule = x: x; # Application does not provide modules.
}));
# See build-setupcfg/default.nix for documentation.
buildSetupcfg = import ../build-support/build-setupcfg self;
fetchPypi = callPackage ../development/interpreters/python/fetchpypi.nix { };
# Check whether a derivation provides a Python module.
hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
# Get list of required Python modules given a list of derivations.
requiredPythonModules = drvs: let
modules = lib.filter hasPythonModule drvs;
in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
# Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations
# providing Python modules.
makePythonPath = drvs: lib.makeSearchPath python.sitePackages (requiredPythonModules drvs);
removePythonPrefix = lib.removePrefix namePrefix;
# Convert derivation to a Python module.
toPythonModule = drv:
drv.overrideAttrs( oldAttrs: {
# Use passthru in order to prevent rebuilds when possible.
passthru = (oldAttrs.passthru or {})// {
pythonModule = python;
pythonPath = [ ]; # Deprecated, for compatibility.
requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
};
});
# Convert a Python library to an application.
toPythonApplication = drv:
drv.overrideAttrs( oldAttrs: {
passthru = (oldAttrs.passthru or {}) // {
# Remove Python prefix from name so we have a "normal" name.
# While the prefix shows up in the store path, it won't be
# used by `nix-env`.
name = removePythonPrefix oldAttrs.name;
pythonModule = false;
};
});
disabled = drv: throw "${removePythonPrefix (drv.pname or drv.name)} not supported for interpreter ${python.executable}";
disabledIf = x: drv: if x then disabled drv else drv;
in {
inherit pkgs stdenv;
inherit (python.passthru) isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy311 isPy3k isPyPy pythonAtLeast pythonOlder;
inherit python bootstrapped-pip buildPythonPackage buildPythonApplication;
inherit fetchPypi;
inherit hasPythonModule requiredPythonModules makePythonPath disabled disabledIf;
inherit toPythonModule toPythonApplication;
inherit buildSetupcfg;
inherit (callPackage ../development/interpreters/python/hooks { })
sphinxHook
condaInstallHook
condaUnpackHook
eggUnpackHook
eggBuildHook
eggInstallHook
flitBuildHook
pipBuildHook
pipInstallHook
pytestCheckHook
pythonCatchConflictsHook
pythonImportsCheckHook
pythonNamespacesHook
pythonOutputDistHook
pythonRecompileBytecodeHook
pythonRelaxDepsHook
pythonRemoveBinBytecodeHook
pythonRemoveTestsDirHook
setuptoolsBuildHook
setuptoolsCheckHook
unittestCheckHook
venvShellHook
wheelUnpackHook;
# helpers
# We use build packages because we are making a setup hook to be used as a
# native build input. The script itself references both the build-time
# (build) and run-time (host) python from the explicitly passed in `python`
# attribute, so the `buildPackages` doesn't effect that.
wrapPython = pkgs.buildPackages.callPackage ../development/interpreters/python/wrap-python.nix {
inherit python;
};
# Dont take pythonPackages from "global" pkgs scope to avoid mixing python versions
pythonPackages = self;
# specials
recursivePthLoader = callPackage ../development/python-modules/recursive-pth-loader { };
setuptools = callPackage ../development/python-modules/setuptools { }; setuptools = callPackage ../development/python-modules/setuptools { };

View File

@ -7,7 +7,7 @@ self: super:
with self; with super; { with self; with super; {
attrs = callPackage ../development/python2-modules/attrs { }; attrs = callPackage ../development/python2-modules/attrs { };
bootstrapped-pip = callPackage ../development/python2-modules/bootstrapped-pip { }; bootstrapped-pip = toPythonModule (callPackage ../development/python2-modules/bootstrapped-pip { });
boto3 = callPackage ../development/python2-modules/boto3 {}; boto3 = callPackage ../development/python2-modules/boto3 {};