about summary refs log tree commit diff
path: root/pkgs/development/python-modules/bootstrap/build/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/bootstrap/build/default.nix')
-rw-r--r--pkgs/development/python-modules/bootstrap/build/default.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/bootstrap/build/default.nix b/pkgs/development/python-modules/bootstrap/build/default.nix
new file mode 100644
index 0000000000000..639d2e3292cb0
--- /dev/null
+++ b/pkgs/development/python-modules/bootstrap/build/default.nix
@@ -0,0 +1,49 @@
+{ lib
+, stdenv
+, python
+, build
+, flit-core
+, installer
+, packaging
+, pyproject-hooks
+, tomli
+}:
+let
+  buildBootstrapPythonModule = basePackage: attrs: stdenv.mkDerivation ({
+    pname = "${python.libPrefix}-bootstrap-${basePackage.pname}";
+    inherit (basePackage) version src meta;
+
+    buildPhase = ''
+      runHook preBuild
+
+      PYTHONPATH="${flit-core}/${python.sitePackages}" \
+        ${python.interpreter} -m flit_core.wheel
+
+      runHook postBuild
+    '';
+
+    installPhase = ''
+      runHook preInstall
+
+      PYTHONPATH="${installer}/${python.sitePackages}" \
+        ${python.interpreter} -m installer \
+          --destdir "$out" --prefix "" dist/*.whl
+
+      runHook postInstall
+    '';
+  } // attrs);
+
+  bootstrap-packaging = buildBootstrapPythonModule packaging {};
+
+  bootstrap-pyproject-hooks = buildBootstrapPythonModule pyproject-hooks {};
+
+  bootstrap-tomli = buildBootstrapPythonModule tomli {};
+in
+buildBootstrapPythonModule build {
+  propagatedBuildInputs = [
+    bootstrap-packaging
+    bootstrap-pyproject-hooks
+  ] ++ lib.optionals (python.pythonOlder "3.11") [
+    bootstrap-tomli
+  ];
+}