f7e28bf5d8
This commit splits the `buildPythonPackage` into multiple setup hooks. Generally, Python packages are built from source to wheels using `setuptools`. The wheels are then installed with `pip`. Tests were often called with `python setup.py test` but this is less common nowadays. Most projects now use a different entry point for running tests, typically `pytest` or `nosetests`. Since the wheel format was introduced more tools were built to generate these, e.g. `flit`. Since PEP 517 is provisionally accepted, defining a build-system independent format (`pyproject.toml`), `pip` can now use that format to execute the correct build-system. In the past I've added support for PEP 517 (`pyproject`) to the Python builder, resulting in a now rather large builder. Furthermore, it was not possible to reuse components elsewhere. Therefore, the builder is now split into multiple setup hooks. The `setuptoolsCheckHook` is included now by default but in time it should be removed from `buildPythonPackage` to make it easier to use another hook (curently one has to pass in `dontUseSetuptoolsCheck`).
95 lines
2.5 KiB
Nix
95 lines
2.5 KiB
Nix
# Hooks for building Python packages.
|
|
{ python
|
|
, callPackage
|
|
, makeSetupHook
|
|
}:
|
|
|
|
let
|
|
pythonInterpreter = python.pythonForBuild.interpreter;
|
|
pythonSitePackages = python.sitePackages;
|
|
pythonCheckInterpreter = python.interpreter;
|
|
setuppy = ../run_setup.py;
|
|
in rec {
|
|
|
|
flitBuildHook = callPackage ({ flit }:
|
|
makeSetupHook {
|
|
name = "flit-build-hook";
|
|
deps = [ flit ];
|
|
substitutions = {
|
|
inherit pythonInterpreter;
|
|
};
|
|
} ./flit-build-hook.sh) {};
|
|
|
|
pipBuildHook = callPackage ({ pip }:
|
|
makeSetupHook {
|
|
name = "pip-build-hook.sh";
|
|
deps = [ pip ];
|
|
substitutions = {
|
|
inherit pythonInterpreter pythonSitePackages;
|
|
};
|
|
} ./pip-build-hook.sh) {};
|
|
|
|
pipInstallHook = callPackage ({ pip }:
|
|
makeSetupHook {
|
|
name = "pip-install-hook";
|
|
deps = [ pip ];
|
|
substitutions = {
|
|
inherit pythonInterpreter pythonSitePackages;
|
|
};
|
|
} ./pip-install-hook.sh) {};
|
|
|
|
pytestCheckHook = callPackage ({ pytest }:
|
|
makeSetupHook {
|
|
name = "pytest-check-hook";
|
|
deps = [ pytest ];
|
|
substitutions = {
|
|
inherit pythonCheckInterpreter;
|
|
};
|
|
} ./pytest-check-hook.sh) {};
|
|
|
|
pythonCatchConflictsHook = callPackage ({ setuptools }:
|
|
makeSetupHook {
|
|
name = "python-catch-conflicts-hook";
|
|
deps = [ setuptools ];
|
|
substitutions = {
|
|
inherit pythonInterpreter;
|
|
catchConflicts=../catch_conflicts/catch_conflicts.py;
|
|
};
|
|
} ./python-catch-conflicts-hook.sh) {};
|
|
|
|
pythonImportsCheckHook = callPackage ({}:
|
|
makeSetupHook {
|
|
name = "python-imports-check-hook.sh";
|
|
substitutions = {
|
|
inherit pythonCheckInterpreter;
|
|
};
|
|
} ./python-imports-check-hook.sh) {};
|
|
|
|
pythonRemoveBinBytecodeHook = callPackage ({ }:
|
|
makeSetupHook {
|
|
name = "python-remove-bin-bytecode-hook";
|
|
} ./python-remove-bin-bytecode-hook.sh) {};
|
|
|
|
setuptoolsBuildHook = callPackage ({ setuptools, wheel }:
|
|
makeSetupHook {
|
|
name = "setuptools-setup-hook";
|
|
deps = [ setuptools wheel ];
|
|
substitutions = {
|
|
inherit pythonInterpreter pythonSitePackages setuppy;
|
|
};
|
|
} ./setuptools-build-hook.sh) {};
|
|
|
|
setuptoolsCheckHook = callPackage ({ setuptools }:
|
|
makeSetupHook {
|
|
name = "setuptools-check-hook";
|
|
deps = [ setuptools ];
|
|
substitutions = {
|
|
inherit pythonCheckInterpreter setuppy;
|
|
};
|
|
} ./setuptools-check-hook.sh) {};
|
|
|
|
wheelUnpackHook = callPackage ({ }:
|
|
makeSetupHook {
|
|
name = "wheel-unpack-hook.sh";
|
|
} ./wheel-unpack-hook.sh) {};
|
|
}
|