about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKirill Boltaev <aske@fmap.me>2019-07-13 00:25:23 +0300
committerFrederik Rietdijk <freddyrietdijk@fridh.nl>2019-07-13 09:47:00 +0200
commit1e0ebdb8a4fe94db67b6520225d325292d60247c (patch)
tree292f1742850af05fcba9d3328835f2b6bc002c0f
parent4aee94629dce852c6021f5ae8ce60de0508d7e37 (diff)
downloadnixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.tar
nixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.tar.gz
nixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.tar.bz2
nixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.tar.lz
nixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.tar.xz
nixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.tar.zst
nixlib-1e0ebdb8a4fe94db67b6520225d325292d60247c.zip
buildPythonPackage: add support for setupPyDistFlags
Flags passed to the "python setup.py" command.
-rw-r--r--doc/languages-frameworks/python.section.md1
-rw-r--r--pkgs/development/interpreters/python/build-python-package-pyproject.nix9
-rw-r--r--pkgs/development/interpreters/python/build-python-package-setuptools.nix9
3 files changed, 14 insertions, 5 deletions
diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md
index 77b387dd3025..ae2f755ff9ac 100644
--- a/doc/languages-frameworks/python.section.md
+++ b/doc/languages-frameworks/python.section.md
@@ -603,6 +603,7 @@ All parameters from `stdenv.mkDerivation` function are still supported. The foll
 * `preShellHook`: Hook to execute commands before `shellHook`.
 * `postShellHook`: Hook to execute commands after `shellHook`.
 * `removeBinByteCode ? true`: Remove bytecode from `/bin`. Bytecode is only created when the filenames end with `.py`.
+* `setupPyDistFlags ? []`: List of flags passed to `setup.py` command.
 * `setupPyBuildFlags ? []`: List of flags passed to `setup.py build_ext` command.
 
 The `stdenv.mkDerivation` function accepts various parameters for describing build inputs (see "Specifying dependencies"). The following are of special
diff --git a/pkgs/development/interpreters/python/build-python-package-pyproject.nix b/pkgs/development/interpreters/python/build-python-package-pyproject.nix
index 86c450fcf92c..38f2f67bfcd9 100644
--- a/pkgs/development/interpreters/python/build-python-package-pyproject.nix
+++ b/pkgs/development/interpreters/python/build-python-package-pyproject.nix
@@ -5,10 +5,12 @@
 }:
 
 {
+# passed to "python setup.py"
+  setupPyDistFlags ? []
 # passed to "python setup.py build_ext"
 # https://github.com/pypa/pip/issues/881
 # Rename to `buildOptions` because it is not setuptools specific?
-  setupPyBuildFlags ? []
+,  setupPyBuildFlags ? []
 # Execute before shell hook
 , preShellHook ? ""
 # Execute after shell hook
@@ -16,13 +18,14 @@
 , ... } @ attrs:
 
 let
+  installOptions = lib.concatMapStringsSep " " (option: "--install-option ${option}") setupPyDistFlags;
   options = lib.concatMapStringsSep " " (option: "--global-option ${option}") setupPyBuildFlags;
 in attrs // {
   buildPhase = attrs.buildPhase or ''
     runHook preBuild
     mkdir -p dist
     echo "Creating a wheel..."
-    ${python.pythonForBuild.interpreter} -m pip wheel --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist ${options} .
+    ${python.pythonForBuild.interpreter} -m pip wheel --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist ${installOptions} ${options} .
     echo "Finished creating a wheel..."
     runHook postBuild
   '';
@@ -50,4 +53,4 @@ in attrs // {
     ${postShellHook}
   '';
 
-}
\ No newline at end of file
+}
diff --git a/pkgs/development/interpreters/python/build-python-package-setuptools.nix b/pkgs/development/interpreters/python/build-python-package-setuptools.nix
index 4c66fdec5f6b..ecb3fed6a042 100644
--- a/pkgs/development/interpreters/python/build-python-package-setuptools.nix
+++ b/pkgs/development/interpreters/python/build-python-package-setuptools.nix
@@ -5,9 +5,11 @@
 }:
 
 {
+# passed to "python setup.py"
+  setupPyDistFlags ? []
 # passed to "python setup.py build_ext"
 # https://github.com/pypa/pip/issues/881
-  setupPyBuildFlags ? []
+,  setupPyBuildFlags ? []
 # Execute before shell hook
 , preShellHook ? ""
 # Execute after shell hook
@@ -19,13 +21,16 @@ let
   # pip does the same thing: https://github.com/pypa/pip/pull/3265
   setuppy = ./run_setup.py;
 
+  setupPyDistFlagsString = lib.concatStringsSep " " setupPyDistFlags;
+  setupPyBuildExtString = lib.optionalString (setupPyBuildFlags != []) ("build_ext " + (lib.concatStringsSep " " setupPyBuildFlags));
+
 in attrs // {
   # we copy nix_run_setup over so it's executed relative to the root of the source
   # many project make that assumption
   buildPhase = attrs.buildPhase or ''
     runHook preBuild
     cp ${setuppy} nix_run_setup
-    ${python.pythonForBuild.interpreter} nix_run_setup ${lib.optionalString (setupPyBuildFlags != []) ("build_ext " + (lib.concatStringsSep " " setupPyBuildFlags))} bdist_wheel
+    ${python.pythonForBuild.interpreter} nix_run_setup ${setupPyDistFlagsString} ${setupPyBuildExtString} bdist_wheel
     runHook postBuild
   '';