diff options
author | Doron Behar <doron.behar@gmail.com> | 2023-07-12 15:37:43 +0300 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2023-07-28 12:13:25 +0200 |
commit | 6560d0086cb710e24ab55670d955e5e96feb7ded (patch) | |
tree | 2b157d76cc75a4e41d958374826c92ede51f21bb | |
parent | 1298c367b106f005c06b8537bd8954d7ff97885c (diff) | |
download | nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.tar nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.tar.gz nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.tar.bz2 nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.tar.lz nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.tar.xz nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.tar.zst nixpkgs-6560d0086cb710e24ab55670d955e5e96feb7ded.zip |
python3.pkgs.pypaBuildHook: init
-rw-r--r-- | doc/languages-frameworks/python.section.md | 8 | ||||
-rw-r--r-- | pkgs/development/interpreters/python/hooks/default.nix | 10 | ||||
-rw-r--r-- | pkgs/development/interpreters/python/hooks/pypa-build-hook.sh | 19 |
3 files changed, 35 insertions, 2 deletions
diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 7d5a4dfc3d0..c8a902c1b0e 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -1189,8 +1189,8 @@ following are specific to `buildPythonPackage`: * `pipInstallFlags ? []`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `pipInstallFlags=["--install-option='--cpp_implementation'"]`. -* `pipBuildFlags ? []`: A list of strings. Arguments to be passed to `pip - wheel`. +* `pipBuildFlags ? []`: A list of strings. Arguments to be passed to `pip wheel`. +* `pypaBuildFlags ? []`: A list of strings. Arguments to be passed to `python -m build --wheel`. * `pythonPath ? []`: List of packages to be added into `$PYTHONPATH`. Packages in `pythonPath` are not propagated (contrary to `propagatedBuildInputs`). * `preShellHook`: Hook to execute commands before `shellHook`. @@ -1485,6 +1485,10 @@ are used in `buildPythonPackage`. - `flitBuildHook` to build a wheel using `flit`. - `pipBuildHook` to build a wheel using `pip` and PEP 517. Note a build system (e.g. `setuptools` or `flit`) should still be added as `nativeBuildInput`. +- `pypaBuildHook` to build a wheel using + [`pypa/build`](https://pypa-build.readthedocs.io/en/latest/index.html) and + PEP 517/518. Note a build system (e.g. `setuptools` or `flit`) should still + be added as `nativeBuildInput`. - `pipInstallHook` to install wheels. - `pytestCheckHook` to run tests with `pytest`. See [example usage](#using-pytestcheckhook). - `pythonCatchConflictsHook` to check whether a Python package is not already existing. diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index 144cc9bb185..bd29d493ebb 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -62,6 +62,16 @@ in { }; } ./pip-build-hook.sh) {}; + pypaBuildHook = callPackage ({ makePythonHook, build, wheel }: + makePythonHook { + name = "pypa-build-hook.sh"; + propagatedBuildInputs = [ build wheel ]; + substitutions = { + inherit pythonInterpreter; + }; + } ./pypa-build-hook.sh) {}; + + pipInstallHook = callPackage ({ makePythonHook, pip }: makePythonHook { name = "pip-install-hook"; diff --git a/pkgs/development/interpreters/python/hooks/pypa-build-hook.sh b/pkgs/development/interpreters/python/hooks/pypa-build-hook.sh new file mode 100644 index 00000000000..3b713004976 --- /dev/null +++ b/pkgs/development/interpreters/python/hooks/pypa-build-hook.sh @@ -0,0 +1,19 @@ +# Setup hook to use for pypa/build projects +echo "Sourcing pypa-build-hook" + +pypaBuildPhase() { + echo "Executing pypaBuildPhase" + runHook preBuild + + echo "Creating a wheel..." + @pythonInterpreter@ -m build --no-isolation --outdir dist/ --wheel $pypaBuildFlags + echo "Finished creating a wheel..." + + runHook postBuild + echo "Finished executing pypaBuildPhase" +} + +if [ -z "${dontUsePypaBuild-}" ] && [ -z "${buildPhase-}" ]; then + echo "Using pypaBuildPhase" + buildPhase=pypaBuildPhase +fi |