Skip to content

Commit

Permalink
doc: Add build hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
adisbladis committed Sep 25, 2024
1 parent d5f8699 commit fa3eeab
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
54 changes: 51 additions & 3 deletions build/hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ let

in
{
# Build hook used to build PEP-621/setuptools projects
/*
Undo any `$PYTHONPATH` changes done by nixpkgs Python infrastructure dependency propagation.
Used internally by `pyprojectHook`.
*/
pyprojectConfigureHook = callPackage (
{ python }:
makeSetupHook {
Expand All @@ -36,7 +40,11 @@ in
} ./pyproject-configure-hook.sh
) { };

# Build hook used to build PEP-621/setuptools projects
/*
Build a pyproject.toml/setuptools project.
Used internally by `pyprojectHook`.
*/
pyprojectBuildHook = callPackage (
_:
makeSetupHook {
Expand All @@ -51,13 +59,23 @@ in
} ./pyproject-build-hook.sh
) { };

/*
Symlink prebuilt wheel sources.
Used internally by `pyprojectWheelHook`.
*/
pyprojectWheelDistHook = callPackage (
_:
makeSetupHook {
name = "pyproject-wheel-dist-hook";
} ./pyproject-wheel-dist-hook.sh
) { };

/*
Install built projects from dist/*.whl.
Used internally by `pyprojectHook`.
*/
pyprojectInstallHook =
callPackage
(
Expand All @@ -73,6 +91,11 @@ in
inherit (buildPackages) uv;
};

/*
Install hook using pypa/installer.
Used instead of `pyprojectInstallHook` for cross compilation support.
*/
pyprojectPypaInstallHook = callPackage (
{ pythonPkgsBuildHost }:
makeSetupHook {
Expand All @@ -84,6 +107,11 @@ in
} ./pyproject-pypa-install-hook.sh
) { };

/*
Clean up any shipped bytecode in package output and recompile.
Used internally by `pyprojectHook`.
*/
pyprojectBytecodeHook = callPackage (
_:
makeSetupHook {
Expand All @@ -103,6 +131,11 @@ in
} ./pyproject-bytecode-hook.sh
) { };

/*
Create `pyproject.nix` setup hook in package output.
Used internally by `pyprojectHook`.
*/
pyprojectOutputSetupHook = callPackage (
_:
makeSetupHook {
Expand All @@ -113,6 +146,11 @@ in
} ./pyproject-output-setup-hook.sh
) { };

/*
Create a virtual environment from buildInputs
Used internally by `mkVirtualEnv`.
*/
pyprojectMakeVenvHook = callPackage (
{ python }:
makeSetupHook {
Expand All @@ -124,7 +162,12 @@ in
} ./pyproject-make-venv-hook.sh
) { };

# Meta hook aggregating the default pyproject.toml/setup.py install behaviour and adds Python
/*
Meta hook aggregating the default pyproject.toml/setup.py install behaviour and adds Python.
This is the default choice for both pyproject.toml & setuptools projects.
*/
#
pyprojectHook =
callPackage
(
Expand Down Expand Up @@ -157,6 +200,11 @@ in
})
);

/*
Hook used to build prebuilt wheels.
Use instead of pyprojectHook.
*/
pyprojectWheelHook = hooks.pyprojectHook.override {
pyprojectBuildHook = hooks.pyprojectWheelDistHook;
};
Expand Down
1 change: 1 addition & 0 deletions doc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- [lib](./build/lib/default.nix)
- [renderers](./build/lib/renderers.nix)
- [resolvers](./build/lib/resolvers.nix)
- [hooks](./build/hooks/default.nix)

# Contributing

Expand Down

0 comments on commit fa3eeab

Please sign in to comment.