From 40851a4d26daabf1613c9a79e638aaf9f94b476c Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sun, 28 May 2017 09:20:47 +0200 Subject: [PATCH 01/10] Python: the pythonModule attribute Python libraries or modules now have an attribute `pythonModule = interpreter;` to indicate they provide Python modules for the specified `interpreter`. The package set provides the following helper functions: - hasPythonModule: Check whether a derivation provides a Python module. - requiredPythonModules: Recurse into a list of Python modules, returning all Python modules that are required. - makePythonPath: Create a PYTHONPATH from a list of Python modules. Also included in this commit is: - disabledIf: Helper function for disabling non-buildPythonPackage functions. --- .../python/build-python-package.nix | 10 +++- .../python/cpython/2.7/default.nix | 2 +- .../python/cpython/3.4/default.nix | 2 +- .../python/cpython/3.5/default.nix | 2 +- .../python/cpython/3.6/default.nix | 2 +- .../python/mk-python-derivation.nix | 9 ++-- .../interpreters/python/pypy/2.7/default.nix | 2 +- .../interpreters/python/wrapper.nix | 7 +-- pkgs/top-level/python-packages.nix | 52 ++++++++++++++++--- 9 files changed, 67 insertions(+), 21 deletions(-) diff --git a/pkgs/development/interpreters/python/build-python-package.nix b/pkgs/development/interpreters/python/build-python-package.nix index b26bf1539cd..29b57834368 100644 --- a/pkgs/development/interpreters/python/build-python-package.nix +++ b/pkgs/development/interpreters/python/build-python-package.nix @@ -5,7 +5,12 @@ { lib , python -, mkPythonDerivation +, wrapPython +, setuptools +, unzip +, ensureNewerSourcesHook +, pythonModule +, namePrefix , bootstrapped-pip , flit }: @@ -15,6 +20,9 @@ let flit-specific = import ./build-python-package-flit.nix { inherit python flit; }; wheel-specific = import ./build-python-package-wheel.nix { }; common = import ./build-python-package-common.nix { inherit python bootstrapped-pip; }; + mkPythonDerivation = import ./mk-python-derivation.nix { + inherit lib python wrapPython setuptools unzip ensureNewerSourcesHook pythonModule namePrefix; + }; in { diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index eb2a46cb3b7..c7483a81529 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -201,7 +201,7 @@ in stdenv.mkDerivation { in rec { inherit libPrefix sitePackages x11Support hasDistutilsCxxPatch; executable = libPrefix; - buildEnv = callPackage ../../wrapper.nix { python = self; }; + buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;}; pkgs = pythonPackages; isPy2 = true; diff --git a/pkgs/development/interpreters/python/cpython/3.4/default.nix b/pkgs/development/interpreters/python/cpython/3.4/default.nix index a924b543fe3..5c13035be1b 100644 --- a/pkgs/development/interpreters/python/cpython/3.4/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.4/default.nix @@ -160,7 +160,7 @@ in stdenv.mkDerivation { in rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; - buildEnv = callPackage ../../wrapper.nix { python = self; }; + buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;}; pkgs = pythonPackages; isPy3 = true; diff --git a/pkgs/development/interpreters/python/cpython/3.5/default.nix b/pkgs/development/interpreters/python/cpython/3.5/default.nix index abe220e0a3e..951cb367528 100644 --- a/pkgs/development/interpreters/python/cpython/3.5/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.5/default.nix @@ -154,7 +154,7 @@ in stdenv.mkDerivation { in rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; - buildEnv = callPackage ../../wrapper.nix { python = self; }; + buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;}; pkgs = pythonPackages; isPy3 = true; diff --git a/pkgs/development/interpreters/python/cpython/3.6/default.nix b/pkgs/development/interpreters/python/cpython/3.6/default.nix index 1614159a7ef..b44e167b9f0 100644 --- a/pkgs/development/interpreters/python/cpython/3.6/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.6/default.nix @@ -153,7 +153,7 @@ in stdenv.mkDerivation { in rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; - buildEnv = callPackage ../../wrapper.nix { python = self; }; + buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;}; pkgs = pythonPackages; isPy3 = true; diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 098ab0b1719..386875a0ab4 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -6,13 +6,13 @@ , setuptools , unzip , ensureNewerSourcesHook +# Whether the derivation provides a Python module or not. +, pythonModule +, namePrefix }: { name ? "${attrs.pname}-${attrs.version}" -# by default prefix `name` e.g. "python3.3-${name}" -, namePrefix ? python.libPrefix + "-" - # Dependencies for building the package , buildInputs ? [] @@ -54,7 +54,7 @@ if disabled then throw "${name} not supported for interpreter ${python.executable}" else -python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "checkInputs"] // { +python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "checkInputs" "pythonModule"] // { name = namePrefix + name; @@ -83,6 +83,7 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "checkInputs" passthru = { inherit python; # The python interpreter + inherit pythonModule; } // passthru; meta = with lib.maintainers; { diff --git a/pkgs/development/interpreters/python/pypy/2.7/default.nix b/pkgs/development/interpreters/python/pypy/2.7/default.nix index f5ee13cfc12..aea389d160f 100644 --- a/pkgs/development/interpreters/python/pypy/2.7/default.nix +++ b/pkgs/development/interpreters/python/pypy/2.7/default.nix @@ -137,7 +137,7 @@ in stdenv.mkDerivation rec { inherit zlibSupport libPrefix sitePackages; executable = "pypy"; isPypy = true; - buildEnv = callPackage ../../wrapper.nix { python = self; }; + buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; interpreter = "${self}/bin/${executable}"; withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;}; pkgs = pythonPackages; diff --git a/pkgs/development/interpreters/python/wrapper.nix b/pkgs/development/interpreters/python/wrapper.nix index f42caf92c17..fc521828ffc 100644 --- a/pkgs/development/interpreters/python/wrapper.nix +++ b/pkgs/development/interpreters/python/wrapper.nix @@ -2,13 +2,14 @@ , extraLibs ? [] , extraOutputsToInstall ? [] , postBuild ? "" -, ignoreCollisions ? false }: +, ignoreCollisions ? false +, requiredPythonModules +, }: # Create a python executable that knows about additional packages. let - recursivePthLoader = import ../../python-modules/recursive-pth-loader/default.nix { stdenv = stdenv; python = python; }; env = let - paths = stdenv.lib.closePropagation (extraLibs ++ [ python recursivePthLoader ] ) ; + paths = requiredPythonModules (extraLibs ++ [ python ] ) ; in buildEnv { name = "${python.name}-env"; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index ad1d50324f6..ea81c4924c1 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -31,10 +31,9 @@ let callPackage = pkgs.newScope self; - bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { }; + namePrefix = python.libPrefix + "-"; - mkPythonDerivation = makeOverridable( callPackage ../development/interpreters/python/mk-python-derivation.nix { - }); + bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { }; # Derivations built with `buildPythonPackage` can already be overriden with `override`, `overrideAttrs`, and `overrideDerivation`. # This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`. @@ -52,13 +51,20 @@ let } else ff; - buildPythonPackage = makeOverridablePythonPackage (callPackage ../development/interpreters/python/build-python-package.nix { - inherit mkPythonDerivation; + buildPythonPackage = makeOverridablePythonPackage ( makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix { inherit bootstrapped-pip; flit = self.flit; - }); + # We want Python libraries to be named like e.g. "python3.6-${name}" + inherit namePrefix; + pythonModule = python; + })); - buildPythonApplication = args: buildPythonPackage ({namePrefix="";} // args ); + buildPythonApplication = makeOverridablePythonPackage ( makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix { + inherit bootstrapped-pip; + flit = self.flit; + namePrefix = ""; + pythonModule = false; + })); graphiteVersion = "1.0.2"; @@ -80,10 +86,40 @@ let else throw "Unsupported kind ${kind}"); in fetcher (builtins.removeAttrs attrs ["format"]) ); + # Check whether a derivation provides a Python module. + hasPythonModule = drv: (hasAttr "pythonModule" drv) && ( (getAttr "pythonModule" drv) == python); + + # Get list of required Python modules given a list of derivations. + requiredPythonModules = drvs: let + filterNull = list: filter (x: !isNull x) list; + conditionalGetRecurse = attr: condition: drv: let f = conditionalGetRecurse attr condition; in + (if (condition drv) then unique [drv]++(concatMap f (filterNull(getAttr attr drv))) else []); + _required = drv: conditionalGetRecurse "propagatedBuildInputs" hasPythonModule drv; + in [python] ++ (unique (concatMap _required (filterNull drvs))); + + # Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations + # providing Python modules. + makePythonPath = drvs: stdenv.lib.makeSearchPath python.sitePackages (requiredPythonModules drvs); + + # Convert derivation to a Python module. + toPythonModule = drv: + drv.overrideAttrs( oldAttrs: { + # Use passthru in order to prevent rebuilds when possible. + passthru = (oldAttrs.passthru or {})// { + name = namePrefix + oldAttrs.name; + pythonModule = python; + pythonPath = [ ]; # Deprecated, for compatibility. + }; + }); + + disabledIf = x: drv: + if x then throw "${removePrefix namePrefix (drv.pname or drv.name)} not supported for interpreter ${python.executable}" else drv; + in { - inherit python bootstrapped-pip pythonAtLeast pythonOlder isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k mkPythonDerivation buildPythonPackage buildPythonApplication; + inherit python bootstrapped-pip pythonAtLeast pythonOlder isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k buildPythonPackage buildPythonApplication; inherit fetchPypi callPackage; + inherit hasPythonModule requiredPythonModules makePythonPath disabledIf; # helpers From 8d9f1701e6969874b97fc2257c9e30131d82aa78 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 20 Oct 2017 20:46:26 +0200 Subject: [PATCH 02/10] python.pkgs: use toPythonModule for packages defined outside python-packages.nix --- pkgs/top-level/python-packages.nix | 56 +++++++++++++----------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index ea81c4924c1..d5e80a37552 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1372,10 +1372,10 @@ in { # Build boost for this specific Python version # TODO: use separate output for libboost_python.so - boost = pkgs.boost.override { + boost = toPythonModule (pkgs.boost.override { inherit (self) python numpy; enablePython = true; - }; + }); buttersink = buildPythonPackage rec { name = "buttersink-0.6.8"; @@ -3236,15 +3236,15 @@ in { propagatedBuildInputs = with self; [ pyusb ]; }; - opencv = pkgs.opencv.override { + opencv = toPythonModule (pkgs.opencv.override { enablePython = true; pythonPackages = self; - }; + }); - opencv3 = pkgs.opencv3.override { + opencv3 = toPythonModule (pkgs.opencv3.override { enablePython = true; pythonPackages = self; - }; + }); openidc-client = callPackage ../development/python-modules/openidc-client/default.nix {}; @@ -4772,12 +4772,10 @@ in { easy-thumbnails = callPackage ../development/python-modules/easy-thumbnails { }; eccodes = if (isPy27) then - (pkgs.eccodes.overrideAttrs (oldattrs: { - name = "${python.libPrefix}-" + oldattrs.name; - })).override { - enablePython = true; - pythonPackages = self; - } else throw "eccodes not supported for interpreter ${python.executable}"; + toPythonModule (pkgs.eccodes.override { + enablePython = true; + pythonPackages = self; + }) else throw "eccodes not supported for interpreter ${python.executable}"; EditorConfig = buildPythonPackage rec { name = "EditorConfig-${version}"; @@ -8747,10 +8745,10 @@ in { folium = callPackage ../development/python-modules/folium { }; - fontforge = pkgs.fontforge.override { + fontforge = toPythonModule (pkgs.fontforge.override { withPython = true; inherit python; - }; + }); fonttools = callPackage ../development/python-modules/fonttools { }; @@ -8924,11 +8922,9 @@ in { }; }; - gdal = (pkgs.gdal.overrideDerivation (oldattrs: { - name = "${python.libPrefix}-" + oldattrs.name; - })).override { + gdal = toPythonModule (pkgs.gdal.override { pythonPackages = self; - }; + }); gdrivefs = buildPythonPackage rec { version = "0.14.8"; @@ -9300,13 +9296,11 @@ in { }; }; - grib-api = if (isPy27) then - (pkgs.grib-api.overrideAttrs (oldattrs: { - name = "${python.libPrefix}-" + oldattrs.name; - })).override { - enablePython = true; - pythonPackages = self; - } else throw "grib-api not supported for interpreter ${python.executable}"; + grib-api = if (isPy27) then toPythonModule + (pkgs.grib-api.override { + enablePython = true; + pythonPackages = self; + }) else throw "grib-api not supported for interpreter ${python.executable}"; gspread = buildPythonPackage rec { version = "0.2.3"; @@ -10409,13 +10403,13 @@ in { }; libplist = if isPy3k then throw "libplist not supported for interpreter ${python.executable}" else - (pkgs.libplist.override{python2Packages=self; }).py; + (toPythonModule (pkgs.libplist.override{python2Packages=self; })).py; libxml2 = if isPy3k then throw "libxml2 not supported for interpreter ${python.executable}" else - (pkgs.libxml2.override{pythonSupport=true; python2=python;}).py; + (toPythonModule (pkgs.libxml2.override{pythonSupport=true; python2=python;})).py; libxslt = if isPy3k then throw "libxslt not supported for interpreter ${python.executable}" else - (pkgs.libxslt.override{pythonSupport=true; python2=python; inherit (self) libxml2;}).py; + (toPythonModule (pkgs.libxslt.override{pythonSupport=true; python2=python; inherit (self) libxml2;})).py; limnoria = buildPythonPackage rec { name = "limnoria-${version}"; @@ -17477,7 +17471,7 @@ in { rply = callPackage ../development/python-modules/rply/default.nix {}; - rpm = (pkgs.rpm.override{inherit python;}); + rpm = toPythonModule (pkgs.rpm.override{inherit python;}); rpmfluff = callPackage ../development/python-modules/rpmfluff {}; @@ -22124,7 +22118,7 @@ EOF }; # For backwards compatibility. Please use nixpkgs.udiskie instead. - udiskie = pkgs.udiskie.override { pythonPackages = self; }; + udiskie = toPythonModule (pkgs.udiskie.override { pythonPackages = self; }); # Should be bumped along with EFL! pythonefl = buildPythonPackage rec { @@ -24461,7 +24455,7 @@ EOF zeep = callPackage ../development/python-modules/zeep { }; zeitgeist = if isPy3k then throw "zeitgeist not supported for interpreter ${python.executable}" else - (pkgs.zeitgeist.override{python2Packages=self;}).py; + (toPythonModule (pkgs.zeitgeist.override{python2Packages=self;})).py; zeroconf = callPackage ../development/python-modules/zeroconf { }; From 95443837443dc5955ff75b03757a2a12796cea9c Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 20 Oct 2017 14:43:19 +0200 Subject: [PATCH 03/10] system-config-printer: recurse into python dependencies pythonPath is used to create the eventual wrappers. It does not recurse into the Python dependencies, which means e.g. requests doesn't haven its dependencies. --- pkgs/tools/misc/system-config-printer/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/tools/misc/system-config-printer/default.nix b/pkgs/tools/misc/system-config-printer/default.nix index 72d45c90f10..11d61cfe30f 100644 --- a/pkgs/tools/misc/system-config-printer/default.nix +++ b/pkgs/tools/misc/system-config-printer/default.nix @@ -28,8 +28,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ wrapGAppsHook ]; - pythonPath = with pythonPackages; - [ pycups pycurl dbus-python pygobject3 requests pycairo pysmbc ]; + pythonPath = with pythonPackages; requiredPythonModules [ pycups pycurl dbus-python pygobject3 requests pycairo pysmbc ]; configureFlags = [ "--with-udev-rules" From 42eece04e4ce4c7cc58f8c53688ad4ed7fc98381 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sat, 11 Nov 2017 13:37:21 +0100 Subject: [PATCH 04/10] python.pkgs.buildPythonPackage: meta.maintainers: don't add chaoflow --- .../interpreters/python/mk-python-derivation.nix | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 386875a0ab4..18d59d2189f 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -86,13 +86,9 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "checkInputs" inherit pythonModule; } // passthru; - meta = with lib.maintainers; { + meta = { # default to python's platforms platforms = python.meta.platforms; - } // meta // { - # add extra maintainer(s) to every package - maintainers = (meta.maintainers or []) ++ [ chaoflow ]; - # a marker for release utilities to discover python packages isBuildPythonPackage = python.meta.platforms; - }; + } // meta; }) From 985f0ce15dc1e19a200959450dff8add32bdeac9 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sat, 11 Nov 2017 13:54:42 +0100 Subject: [PATCH 05/10] python.pkgs.rivet: add bindings for rivet --- pkgs/development/libraries/physics/rivet/default.nix | 2 -- pkgs/top-level/python-packages.nix | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/physics/rivet/default.nix b/pkgs/development/libraries/physics/rivet/default.nix index 454c868dfcd..3e80e575852 100644 --- a/pkgs/development/libraries/physics/rivet/default.nix +++ b/pkgs/development/libraries/physics/rivet/default.nix @@ -11,8 +11,6 @@ stdenv.mkDerivation rec { postPatch = "patchShebangs ./src/Analyses/cat_with_lines"; - pythonPath = []; # python wrapper support - patches = [ ./darwin.patch # configure relies on impure sw_vers to -Dunix ]; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index d5e80a37552..e27065d1973 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17200,6 +17200,10 @@ in { readme_renderer = callPackage ../development/python-modules/readme_renderer { }; + rivet = disabledIf isPy3k (toPythonModule (pkgs.rivet.override { + python2 = python; + })); + rjsmin = callPackage ../development/python-modules/rjsmin { }; pysolr = buildPythonPackage rec { From 209ee2f20f10bd9cd895b7e2df5161c163233365 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sat, 11 Nov 2017 16:21:02 +0100 Subject: [PATCH 06/10] python.pkgs.buildPythonPackage: do not pass attributes that stdenv.mkDerivation does not use --- .../development/interpreters/python/mk-python-derivation.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 18d59d2189f..b7327706d24 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -54,11 +54,12 @@ if disabled then throw "${name} not supported for interpreter ${python.executable}" else -python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "checkInputs" "pythonModule"] // { +python.stdenv.mkDerivation (builtins.removeAttrs attrs [ + "disabled" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" + ] // { name = namePrefix + name; - inherit pythonPath; buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath ++ [ (ensureNewerSourcesHook { year = "1980"; }) ] From 7c3c2a0dcabf21478d4f895fd4aef6a9606d3835 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sat, 11 Nov 2017 16:23:47 +0100 Subject: [PATCH 07/10] python.pkgs.pytest: add missing setuptools dependency --- pkgs/development/python-modules/pytest/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/pytest/default.nix b/pkgs/development/python-modules/pytest/default.nix index 42a591e58b6..465d63d632f 100644 --- a/pkgs/development/python-modules/pytest/default.nix +++ b/pkgs/development/python-modules/pytest/default.nix @@ -1,10 +1,9 @@ { stdenv, buildPythonPackage, fetchPypi, isPy26, argparse, hypothesis, py -, setuptools_scm +, setuptools_scm, setuptools }: buildPythonPackage rec { version = "3.2.3"; pname = "pytest"; - name = "${pname}-${version}"; preCheck = '' # don't test bash builtins @@ -16,8 +15,9 @@ buildPythonPackage rec { sha256 = "27fa6617efc2869d3e969a3e75ec060375bfb28831ade8b5cdd68da3a741dc3c"; }; - buildInputs = [ hypothesis setuptools_scm ]; - propagatedBuildInputs = [ py ] + checkInputs = [ hypothesis ]; + buildInputs = [ setuptools_scm ]; + propagatedBuildInputs = [ py setuptools ] ++ (stdenv.lib.optional isPy26 argparse); meta = with stdenv.lib; { From 80329e71235d088e590ae044e96dabeb4ace3215 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sat, 11 Nov 2017 16:24:38 +0100 Subject: [PATCH 08/10] python.pkgs.buildPythonPackage: some comments --- .../interpreters/python/build-python-package.nix | 6 ++---- .../interpreters/python/mk-python-derivation.nix | 14 ++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/development/interpreters/python/build-python-package.nix b/pkgs/development/interpreters/python/build-python-package.nix index 29b57834368..982542c1fc3 100644 --- a/pkgs/development/interpreters/python/build-python-package.nix +++ b/pkgs/development/interpreters/python/build-python-package.nix @@ -1,7 +1,5 @@ -/* This function provides a generic Python package builder. It is - intended to work with packages that use `distutils/setuptools' - (http://pypi.python.org/pypi/setuptools/), which represents a large - number of Python packages nowadays. */ +# This function provides a generic Python package builder, +# and can build packages that use distutils, setuptools or flit. { lib , python diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index b7327706d24..a0cac7d1ddd 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -1,4 +1,4 @@ -/* Generic builder for Python packages that come without a setup.py. */ +# Generic builder. { lib , python @@ -60,13 +60,15 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs [ name = namePrefix + name; - - buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath - ++ [ (ensureNewerSourcesHook { year = "1980"; }) ] + buildInputs = ([ wrapPython (ensureNewerSourcesHook { year = "1980"; }) ] ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip) - ++ lib.optionals doCheck checkInputs; + ++ lib.optionals doCheck checkInputs + ++ lib.optional catchConflicts setuptools # If we nog longer propagate setuptools + ++ buildInputs + ++ pythonPath + ); - # propagate python/setuptools to active setup-hook in nix-shell + # Propagate python and setuptools. We should stop propagating setuptools. propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ]; # Python packages don't have a checkPhase, only an installCheckPhase From 24b7b3e49f93e85df53f64e727cd9c63305372c5 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sun, 12 Nov 2017 18:31:17 +0100 Subject: [PATCH 09/10] python.pkgs.setuptools: 36.4.0/36.6.0 -> 36.7.1 --- pkgs/development/python-modules/bootstrapped-pip/default.nix | 4 ++-- pkgs/development/python-modules/setuptools/default.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix index 0cb817844c7..9ff0b144f10 100644 --- a/pkgs/development/python-modules/bootstrapped-pip/default.nix +++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix @@ -9,9 +9,9 @@ let }; setuptools_source = fetchPypi { pname = "setuptools"; - version = "36.4.0"; + version = "36.7.1"; format = "wheel"; - sha256 = "4d54c0bfee283e78609169213f9c075827d5837086f58b588b417b093c23464b"; + sha256 = "eaacfa35eb11199d0b017df416421781a75209817bff3f94820556e36c49bd77"; }; # TODO: Shouldn't be necessary anymore for pip > 9.0.1! diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix index a65b0206ee5..3c919db42f4 100644 --- a/pkgs/development/python-modules/setuptools/default.nix +++ b/pkgs/development/python-modules/setuptools/default.nix @@ -8,13 +8,13 @@ # Should use buildPythonPackage here somehow stdenv.mkDerivation rec { pname = "setuptools"; - version = "36.6.0"; + version = "36.7.1"; name = "${python.libPrefix}-${pname}-${version}"; src = fetchPypi { inherit pname version; extension = "zip"; - sha256 = "62074589522a798da243f47348f38020d55b6c945652e2f2c09d3a96299812b7"; + sha256 = "543becf5d33d8989dc5222403997488e9dc3872bdecdabb0f57184ca253ec1e8"; }; buildInputs = [ python wrapPython unzip ]; From 59d82d889577bfbdeeb47912eb245846f33e0ae2 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sun, 12 Nov 2017 18:58:57 +0100 Subject: [PATCH 10/10] python.pkgs: use disabledIf --- pkgs/top-level/python-packages.nix | 44 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e27065d1973..2d640b9af60 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -190,9 +190,7 @@ in { breathe = callPackage ../development/python-modules/breathe { }; - browsermob-proxy = if ! isPy3k then - callPackage ../development/python-modules/browsermob-proxy {} - else throw "browsermob-proxy is not supported for ${python.executable}"; + browsermob-proxy = disabledIf isPy3k (callPackage ../development/python-modules/browsermob-proxy {}); bugseverywhere = callPackage ../applications/version-management/bugseverywhere {}; @@ -258,11 +256,11 @@ in { pyamf = callPackage ../development/python-modules/pyamf { }; - pyatspi = if isPy3k then callPackage ../development/python-modules/pyatspi { } else throw "pyatspi not supported for interpreter ${python.executable}"; + pyatspi = disabledIf (!isPy3k) (callPackage ../development/python-modules/pyatspi { }); pycairo = callPackage ../development/python-modules/pycairo { }; - pycangjie = if isPy3k then callPackage ../development/python-modules/pycangjie { } else throw "pycangjie not supported for interpreter ${python.executable}"; + pycangjie = disabledIf (!isPy3k) (callPackage ../development/python-modules/pycangjie { }); pycrypto = callPackage ../development/python-modules/pycrypto { }; @@ -272,7 +270,7 @@ in { PyChromecast = callPackage ../development/python-modules/pychromecast { }; - pyexiv2 = if (!isPy3k) then callPackage ../development/python-modules/pyexiv2 {} else throw "pyexiv2 not supported for interpreter ${python.executable}"; + pyexiv2 = disabledIf isPy3k (callPackage ../development/python-modules/pyexiv2 {}); py3exiv2 = callPackage ../development/python-modules/py3exiv2 { }; @@ -334,13 +332,13 @@ in { PyWebDAV = callPackage ../development/python-modules/pywebdav { }; - pyxml = if !isPy3k then callPackage ../development/python-modules/pyxml{ } else throw "pyxml not supported for interpreter ${python.executable}"; + pyxml = disabledIf isPy3k (callPackage ../development/python-modules/pyxml{ }); relatorio = callPackage ../development/python-modules/relatorio { }; pyzufall = callPackage ../development/python-modules/pyzufall { }; - rhpl = if !isPy3k then callPackage ../development/python-modules/rhpl {} else throw "rhpl not supported for interpreter ${python.executable}"; + rhpl = disabledIf isPy3k (callPackage ../development/python-modules/rhpl {}); simpleeval = callPackage ../development/python-modules/simpleeval { }; @@ -4771,11 +4769,11 @@ in { easy-thumbnails = callPackage ../development/python-modules/easy-thumbnails { }; - eccodes = if (isPy27) then - toPythonModule (pkgs.eccodes.override { + eccodes = disabledIf (!isPy27) + (toPythonModule (pkgs.eccodes.override { enablePython = true; pythonPackages = self; - }) else throw "eccodes not supported for interpreter ${python.executable}"; + })); EditorConfig = buildPythonPackage rec { name = "EditorConfig-${version}"; @@ -9296,11 +9294,11 @@ in { }; }; - grib-api = if (isPy27) then toPythonModule + grib-api = disabledIf (!isPy27) (toPythonModule (pkgs.grib-api.override { enablePython = true; pythonPackages = self; - }) else throw "grib-api not supported for interpreter ${python.executable}"; + })); gspread = buildPythonPackage rec { version = "0.2.3"; @@ -10402,13 +10400,13 @@ in { inherit (pkgs) libsodium; }; - libplist = if isPy3k then throw "libplist not supported for interpreter ${python.executable}" else + libplist = disabledIf isPy3k (toPythonModule (pkgs.libplist.override{python2Packages=self; })).py; - libxml2 = if isPy3k then throw "libxml2 not supported for interpreter ${python.executable}" else + libxml2 = disabledIf isPy3k (toPythonModule (pkgs.libxml2.override{pythonSupport=true; python2=python;})).py; - libxslt = if isPy3k then throw "libxslt not supported for interpreter ${python.executable}" else + libxslt = disabledIf isPy3k (toPythonModule (pkgs.libxslt.override{pythonSupport=true; python2=python; inherit (self) libxml2;})).py; limnoria = buildPythonPackage rec { @@ -17021,9 +17019,8 @@ in { }; }; - qscintilla = if isPy3k || isPyPy - then throw "qscintilla-${pkgs.qscintilla.version} not supported for interpreter ${python.executable}" - else buildPythonPackage rec { + qscintilla = disabledIf (isPy3k || isPyPy) + (buildPythonPackage rec { # TODO: Qt5 support name = "qscintilla-${version}"; version = pkgs.qscintilla.version; @@ -17052,7 +17049,7 @@ in { maintainers = with maintainers; [ danbst ]; platforms = platforms.linux; }; - }; + }); qserve = buildPythonPackage rec { @@ -24384,9 +24381,8 @@ EOF ROPGadget = callPackage ../development/python-modules/ROPGadget { }; # We need "normal" libxml2 and not the python package by the same name. - pywbem = if !(isPy36) - then callPackage ../development/python-modules/pywbem { libxml2 = pkgs.libxml2; } - else throw "pywbem not supported for interpreter ${python.executable}"; + pywbem = disabledIf isPy36 + (callPackage ../development/python-modules/pywbem { libxml2 = pkgs.libxml2; }); unicorn = callPackage ../development/python-modules/unicorn { }; @@ -24458,7 +24454,7 @@ EOF zeep = callPackage ../development/python-modules/zeep { }; - zeitgeist = if isPy3k then throw "zeitgeist not supported for interpreter ${python.executable}" else + zeitgeist = disabledIf isPy3k (toPythonModule (pkgs.zeitgeist.override{python2Packages=self;})).py; zeroconf = callPackage ../development/python-modules/zeroconf { };