From b080748d42d18a3a51e4afacc962d9528ae4200d Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 31 Aug 2016 10:13:15 +0200 Subject: [PATCH 1/6] Python: move python-modules/generic to interpreter folder --- doc/languages-frameworks/python.md | 2 +- .../python/buildpythonpackage.nix} | 0 .../generic => interpreters/python}/catch_conflicts.py | 0 .../generic => interpreters/python}/run_setup.py | 0 .../{python-modules/generic => interpreters/python}/wrap.sh | 0 pkgs/top-level/python-packages.nix | 4 ++-- 6 files changed, 3 insertions(+), 3 deletions(-) rename pkgs/development/{python-modules/generic/default.nix => interpreters/python/buildpythonpackage.nix} (100%) rename pkgs/development/{python-modules/generic => interpreters/python}/catch_conflicts.py (100%) rename pkgs/development/{python-modules/generic => interpreters/python}/run_setup.py (100%) rename pkgs/development/{python-modules/generic => interpreters/python}/wrap.sh (100%) diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md index c38266413bf..ffda162ffde 100644 --- a/doc/languages-frameworks/python.md +++ b/doc/languages-frameworks/python.md @@ -481,7 +481,7 @@ and the aliases #### `buildPythonPackage` function The `buildPythonPackage` function is implemented in -`pkgs/development/python-modules/generic/default.nix` +`pkgs/development/interpreters/python/buildpythonpackage.nix` and can be used as: diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/interpreters/python/buildpythonpackage.nix similarity index 100% rename from pkgs/development/python-modules/generic/default.nix rename to pkgs/development/interpreters/python/buildpythonpackage.nix diff --git a/pkgs/development/python-modules/generic/catch_conflicts.py b/pkgs/development/interpreters/python/catch_conflicts.py similarity index 100% rename from pkgs/development/python-modules/generic/catch_conflicts.py rename to pkgs/development/interpreters/python/catch_conflicts.py diff --git a/pkgs/development/python-modules/generic/run_setup.py b/pkgs/development/interpreters/python/run_setup.py similarity index 100% rename from pkgs/development/python-modules/generic/run_setup.py rename to pkgs/development/interpreters/python/run_setup.py diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/interpreters/python/wrap.sh similarity index 100% rename from pkgs/development/python-modules/generic/wrap.sh rename to pkgs/development/interpreters/python/wrap.sh diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 574cff47122..991ceaf1f12 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18,7 +18,7 @@ let bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { }; - buildPythonPackage = makeOverridable (callPackage ../development/python-modules/generic { + buildPythonPackage = makeOverridable (callPackage ../development/interpreters/python/buildpythonpackage.nix { inherit bootstrapped-pip; }); @@ -82,7 +82,7 @@ in modules // { } ''; } - ../development/python-modules/generic/wrap.sh; + ../development/interpreters/python/wrap.sh; # specials From 725c37b4d350c9c040c29efd8146619f77c897f5 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 31 Aug 2016 10:22:19 +0200 Subject: [PATCH 2/6] Python: move wrapPython into own file --- .../interpreters/python/wrap-python.nix | 51 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 46 +---------------- 2 files changed, 52 insertions(+), 45 deletions(-) create mode 100644 pkgs/development/interpreters/python/wrap-python.nix diff --git a/pkgs/development/interpreters/python/wrap-python.nix b/pkgs/development/interpreters/python/wrap-python.nix new file mode 100644 index 00000000000..b965ff5350b --- /dev/null +++ b/pkgs/development/interpreters/python/wrap-python.nix @@ -0,0 +1,51 @@ +{ lib +, python +, makeSetupHook +, makeWrapper }: + +with lib; + +makeSetupHook { + deps = makeWrapper; + substitutions.libPrefix = python.libPrefix; + substitutions.executable = python.interpreter; + substitutions.python = python; + substitutions.magicalSedExpression = let + # Looks weird? Of course, it's between single quoted shell strings. + # NOTE: Order DOES matter here, so single character quotes need to be + # at the last position. + quoteVariants = [ "'\"'''\"'" "\"\"\"" "\"" "'\"'\"'" ]; # hey Vim: '' + + mkStringSkipper = labelNum: quote: let + label = "q${toString labelNum}"; + isSingle = elem quote [ "\"" "'\"'\"'" ]; + endQuote = if isSingle then "[^\\\\]${quote}" else quote; + in '' + /^[a-z]?${quote}/ { + /${quote}${quote}|${quote}.*${endQuote}/{n;br} + :${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label} + } + ''; + + # This preamble does two things: + # * Sets argv[0] to the original application's name; otherwise it would be .foo-wrapped. + # Python doesn't support `exec -a`. + # * Adds all required libraries to sys.path via `site.addsitedir`. It also handles *.pth files. + preamble = '' + import sys + import site + import functools + sys.argv[0] = '"'$(basename "$f")'"' + functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo()) + ''; + + in '' + 1 { + :r + /\\$|,$/{N;br} + /__future__|^ |^ *(#.*)?$/{n;br} + ${concatImapStrings mkStringSkipper quoteVariants} + /^[^# ]/i ${replaceStrings ["\n"] [";"] preamble} + } + ''; +} ./wrap.sh diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 991ceaf1f12..9b70ab87dc2 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -38,51 +38,7 @@ in modules // { # helpers - wrapPython = pkgs.makeSetupHook - { deps = pkgs.makeWrapper; - substitutions.libPrefix = python.libPrefix; - substitutions.executable = python.interpreter; - substitutions.python = python; - substitutions.magicalSedExpression = let - # Looks weird? Of course, it's between single quoted shell strings. - # NOTE: Order DOES matter here, so single character quotes need to be - # at the last position. - quoteVariants = [ "'\"'''\"'" "\"\"\"" "\"" "'\"'\"'" ]; # hey Vim: '' - - mkStringSkipper = labelNum: quote: let - label = "q${toString labelNum}"; - isSingle = elem quote [ "\"" "'\"'\"'" ]; - endQuote = if isSingle then "[^\\\\]${quote}" else quote; - in '' - /^[a-z]?${quote}/ { - /${quote}${quote}|${quote}.*${endQuote}/{n;br} - :${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label} - } - ''; - - # This preamble does two things: - # * Sets argv[0] to the original application's name; otherwise it would be .foo-wrapped. - # Python doesn't support `exec -a`. - # * Adds all required libraries to sys.path via `site.addsitedir`. It also handles *.pth files. - preamble = '' - import sys - import site - import functools - sys.argv[0] = '"'$(basename "$f")'"' - functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo()) - ''; - - in '' - 1 { - :r - /\\$|,$/{N;br} - /__future__|^ |^ *(#.*)?$/{n;br} - ${concatImapStrings mkStringSkipper quoteVariants} - /^[^# ]/i ${replaceStrings ["\n"] [";"] preamble} - } - ''; - } - ../development/interpreters/python/wrap.sh; + wrapPython = callPackage ../development/interpreters/python/wrap-python.nix {inherit python; inherit (pkgs) makeSetupHook makeWrapper; }; # specials From 3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 17 Aug 2016 14:23:47 +0200 Subject: [PATCH 3/6] Python: separate buildPythonPackage into two functions 1. mkDerivation which is used when the source is without setup.py and not a wheel 2. buildPythonPackage which is used as before and calls mkDerivation --- doc/languages-frameworks/python.md | 2 +- ...onpackage.nix => build-python-package.nix} | 80 ++++------------- .../python/mk-python-derivation.nix | 87 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 7 +- 4 files changed, 109 insertions(+), 67 deletions(-) rename pkgs/development/interpreters/python/{buildpythonpackage.nix => build-python-package.nix} (58%) create mode 100644 pkgs/development/interpreters/python/mk-python-derivation.nix diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md index ffda162ffde..67354fa4914 100644 --- a/doc/languages-frameworks/python.md +++ b/doc/languages-frameworks/python.md @@ -481,7 +481,7 @@ and the aliases #### `buildPythonPackage` function The `buildPythonPackage` function is implemented in -`pkgs/development/interpreters/python/buildpythonpackage.nix` +`pkgs/development/interpreters/python/build-python-package.nix` and can be used as: diff --git a/pkgs/development/interpreters/python/buildpythonpackage.nix b/pkgs/development/interpreters/python/build-python-package.nix similarity index 58% rename from pkgs/development/interpreters/python/buildpythonpackage.nix rename to pkgs/development/interpreters/python/build-python-package.nix index 38d74e08244..a92296cedba 100644 --- a/pkgs/development/interpreters/python/buildpythonpackage.nix +++ b/pkgs/development/interpreters/python/build-python-package.nix @@ -3,57 +3,37 @@ (http://pypi.python.org/pypi/setuptools/), which represents a large number of Python packages nowadays. */ -{ python, setuptools, unzip, wrapPython, lib, bootstrapped-pip -, ensureNewerSourcesHook }: +{ lib +, python +, mkPythonDerivation +, bootstrapped-pip +}: -{ name - -# by default prefix `name` e.g. "python3.3-${name}" -, namePrefix ? python.libPrefix + "-" - -, buildInputs ? [] +{ buildInputs ? [] # propagate build dependencies so in case we have A -> B -> C, -# C can import package A propagated by B -, propagatedBuildInputs ? [] +# C can import package A propagated by B +#, propagatedBuildInputs ? [] # passed to "python setup.py build_ext" # https://github.com/pypa/pip/issues/881 , setupPyBuildFlags ? [] -# DEPRECATED: use propagatedBuildInputs -, pythonPath ? [] - -# used to disable derivation, useful for specific python versions -, disabled ? false - -, meta ? {} - # Execute before shell hook , preShellHook ? "" # Execute after shell hook , postShellHook ? "" -# Additional arguments to pass to the makeWrapper function, which wraps -# generated binaries. -, makeWrapperArgs ? [] - # Additional flags to pass to "pip install". , installFlags ? [] -# Raise an error if two packages are installed with the same name -, catchConflicts ? true - , format ? "setup" , ... } @ attrs: -# Keep extra attributes from `attrs`, e.g., `patchPhase', etc. -if disabled -then throw "${name} not supported for interpreter ${python.executable}" -else + let # use setuptools shim (so that setuptools is imported before distutils) @@ -73,14 +53,10 @@ let installCheckPhase = attrs.checkPhase or ":"; # Wheels don't have any checks to run - doInstallCheck = attrs.doCheck or false; + doCheck = attrs.doCheck or false; } else if format == "setup" then { - # propagate python/setuptools to active setup-hook in nix-shell - propagatedBuildInputs = - propagatedBuildInputs ++ [ python setuptools ]; - # we copy nix_run_setup.py over so it's executed relative to the root of the source # many project make that assumption buildPhase = attrs.buildPhase or '' @@ -100,21 +76,17 @@ let # are typically distributed with tests. # With Python it's a common idiom to run the tests # after the software has been installed. - - # For backwards compatibility, let's use an alias - doInstallCheck = attrs.doCheck or true; + doCheck = attrs.doCheck or true; } else throw "Unsupported format ${format}"; -in -python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] // { - name = namePrefix + name; - buildInputs = [ wrapPython bootstrapped-pip ] ++ buildInputs ++ pythonPath - ++ [ (ensureNewerSourcesHook { year = "1980"; }) ] - ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip); +in mkPythonDerivation ( attrs // { - pythonPath = pythonPath; + # To build and install a wheel we need pip + buildInputs = buildInputs ++ [ bootstrapped-pip ]; + +#inherit propagatedBuildInputs; configurePhase = attrs.configurePhase or '' runHook preConfigure @@ -126,9 +98,6 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] // runHook postConfigure ''; - # Python packages don't have a checkPhase, only an installCheckPhase - doCheck = false; - installPhase = attrs.installPhase or '' runHook preInstall @@ -142,14 +111,6 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] // runHook postInstall ''; - postFixup = attrs.postFixup or '' - wrapPythonPrograms - '' + lib.optionalString catchConflicts '' - # check if we have two packages with the same name in closure and fail - # this shouldn't happen, something went wrong with dependencies specs - ${python.interpreter} ${./catch_conflicts.py} - ''; - shellHook = attrs.shellHook or '' ${preShellHook} if test -e setup.py; then @@ -162,13 +123,4 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] // ${postShellHook} ''; - meta = with lib.maintainers; { - # default to python's platforms - platforms = python.meta.platforms; - } // meta // { - # add extra maintainer(s) to every package - maintainers = (meta.maintainers or []) ++ [ chaoflow domenkozar ]; - # a marker for release utilities to discover python packages - isBuildPythonPackage = python.meta.platforms; - }; } // formatspecific) diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix new file mode 100644 index 00000000000..e46f9afde96 --- /dev/null +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -0,0 +1,87 @@ +/* Generic builder for Python packages that come without a setup.py. */ + +{ lib +, python +, wrapPython +, setuptools +, unzip +, ensureNewerSourcesHook +}: + +{ name + +# by default prefix `name` e.g. "python3.3-${name}" +, namePrefix ? python.libPrefix + "-" + +, buildInputs ? [] + +# propagate build dependencies so in case we have A -> B -> C, +# C can import package A propagated by B +, propagatedBuildInputs ? [] + +# DEPRECATED: use propagatedBuildInputs +, pythonPath ? [] + +# used to disable derivation, useful for specific python versions +, disabled ? false + +# Raise an error if two packages are installed with the same name +, catchConflicts ? true + +# Additional arguments to pass to the makeWrapper function, which wraps +# generated binaries. +, makeWrapperArgs ? [] + +, meta ? {} + +, passthru ? {} + +, ... } @ attrs: + + +# Keep extra attributes from `attrs`, e.g., `patchPhase', etc. +if disabled +then throw "${name} not supported for interpreter ${python.executable}" +else + +python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // { + + name = namePrefix + name; + + inherit pythonPath; + + buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath + ++ [ (ensureNewerSourcesHook { year = "1980"; }) ] + ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip); + + # propagate python/setuptools to active setup-hook in nix-shell + propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ]; + + # Python packages don't have a checkPhase, only an installCheckPhase + doCheck = false; + doInstallCheck = attrs.doCheck or false; + + postFixup = attrs.postFixup or '' + wrapPythonPrograms + '' + lib.optionalString catchConflicts '' + # check if we have two packages with the same name in closure and fail + # this shouldn't happen, something went wrong with dependencies specs + ${python.interpreter} ${./catch_conflicts.py} + ''; + + passthru = { + inherit python; # The python interpreter + } // passthru; + + meta = with lib.maintainers; { + # default to python's platforms + platforms = python.meta.platforms; + } // meta // { + # add extra maintainer(s) to every package + maintainers = (meta.maintainers or []) ++ [ chaoflow domenkozar ]; + # a marker for release utilities to discover python packages + isBuildPythonPackage = python.meta.platforms; + }; +}) + + diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9b70ab87dc2..157886edfb4 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18,7 +18,10 @@ let bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { }; - buildPythonPackage = makeOverridable (callPackage ../development/interpreters/python/buildpythonpackage.nix { + mkPythonDerivation = makeOverridable( callPackage ../development/interpreters/python/mk-python-derivation.nix { + }); + buildPythonPackage = makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix { + inherit mkPythonDerivation; inherit bootstrapped-pip; }); @@ -34,7 +37,7 @@ let in modules // { - inherit python bootstrapped-pip isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k buildPythonPackage buildPythonApplication; + inherit python bootstrapped-pip isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k mkPythonDerivation buildPythonPackage buildPythonApplication; # helpers From e9c4d00cacea699c0e23e7c09967dd3fe12edc23 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 31 Aug 2016 10:57:59 +0200 Subject: [PATCH 4/6] pythonPackages.fedora_cert: use mkPythonDerivation, fix build --- pkgs/top-level/python-packages.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 157886edfb4..867edd0805e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6336,7 +6336,7 @@ in modules // { buildInputs = with self; [ fudge_9 nose ]; }; - fedora_cert = stdenv.mkDerivation (rec { + fedora_cert = mkPythonDerivation rec { name = "fedora-cert-0.5.9.2"; meta.maintainers = with maintainers; [ mornfall ]; @@ -6345,12 +6345,10 @@ in modules // { sha256 = "105swvzshgn3g6bjwk67xd8pslnhpxwa63mdsw6cl4c7cjp2blx9"; }; - propagatedBuildInputs = with self; [ python python_fedora wrapPython ]; + propagatedBuildInputs = with self; [ python_fedora modules.sqlite3 pyopenssl ]; postInstall = "mv $out/bin/fedpkg $out/bin/fedora-cert-fedpkg"; doCheck = false; - - postFixup = "wrapPythonPrograms"; - }); + }; fedpkg = buildPythonPackage (rec { name = "fedpkg-1.14"; From 4f6b6f14726296c1d402f187db995031bccd791f Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 31 Aug 2016 11:01:16 +0200 Subject: [PATCH 5/6] pythonPackages: use mkPythonDerivation --- doc/languages-frameworks/python.md | 1 + .../interpreters/python/mk-python-derivation.nix | 8 +++++++- pkgs/development/python-modules/dbus/default.nix | 16 ++++++---------- .../python-modules/pycairo/default.nix | 8 ++++---- pkgs/development/python-modules/pygobject/3.nix | 10 ++++------ .../python-modules/pygobject/default.nix | 8 +++----- .../python-modules/pygtksourceview/default.nix | 6 +++--- pkgs/development/python-modules/pyqt/4.x.nix | 15 +++++++-------- pkgs/development/python-modules/pyqt/5.x.nix | 14 ++++++-------- .../python-modules/pyside/default.nix | 2 +- .../development/python-modules/pyxml/default.nix | 13 ++++++------- pkgs/development/python-modules/sip/default.nix | 10 +++------- pkgs/top-level/python-packages.nix | 10 +++++----- 13 files changed, 56 insertions(+), 65 deletions(-) diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md index 67354fa4914..e7dbe3bd7db 100644 --- a/doc/languages-frameworks/python.md +++ b/doc/languages-frameworks/python.md @@ -536,6 +536,7 @@ All parameters from `mkDerivation` function are still supported. * `installFlags`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"]. * `format`: Format of the source. Options are `setup` for when the source has a `setup.py` and `setuptools` is used to build a wheel, and `wheel` in case the source is already a binary wheel. The default value is `setup`. * `catchConflicts` If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`. +* `checkInputs` Dependencies needed for running the `checkPhase`. These are added to `buildInputs` when `doCheck = true`. #### `buildPythonApplication` function diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index e46f9afde96..47e55be4baf 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -13,8 +13,13 @@ # by default prefix `name` e.g. "python3.3-${name}" , namePrefix ? python.libPrefix + "-" +# Dependencies for building the package , buildInputs ? [] +# Dependencies needed for running the checkPhase. +# These are added to buildInputs when doCheck = true. +, checkInputs ? [] + # propagate build dependencies so in case we have A -> B -> C, # C can import package A propagated by B , propagatedBuildInputs ? [] @@ -52,7 +57,8 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // { buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath ++ [ (ensureNewerSourcesHook { year = "1980"; }) ] - ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip); + ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip) + ++ lib.optionals attrs.doCheck checkInputs; # propagate python/setuptools to active setup-hook in nix-shell propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ]; diff --git a/pkgs/development/python-modules/dbus/default.nix b/pkgs/development/python-modules/dbus/default.nix index e99a10ab1c4..f3f897ac9e7 100644 --- a/pkgs/development/python-modules/dbus/default.nix +++ b/pkgs/development/python-modules/dbus/default.nix @@ -1,7 +1,7 @@ -{ stdenv, fetchurl, python, pkgconfig, dbus, dbus_glib, dbus_tools, isPyPy +{ lib, fetchurl, mkPythonDerivation, python, pkgconfig, dbus, dbus_glib, dbus_tools, isPyPy , ncurses, pygobject3 }: -if isPyPy then throw "dbus-python not supported for interpreter ${python.executable}" else stdenv.mkDerivation rec { +if isPyPy then throw "dbus-python not supported for interpreter ${python.executable}" else mkPythonDerivation rec { name = "dbus-python-1.2.4"; src = fetchurl { @@ -11,21 +11,17 @@ if isPyPy then throw "dbus-python not supported for interpreter ${python.executa postPatch = "patchShebangs ."; - buildInputs = [ python pkgconfig dbus dbus_glib ] - ++ stdenv.lib.optionals doCheck [ dbus_tools pygobject3 ] + buildInputs = [ pkgconfig dbus dbus_glib ] + ++ lib.optionals doCheck [ dbus_tools pygobject3 ] # My guess why it's sometimes trying to -lncurses. # It seems not to retain the dependency anyway. - ++ stdenv.lib.optional (! python ? modules) ncurses; + ++ lib.optional (! python ? modules) ncurses; doCheck = true; - # Set empty pythonPath, so that the package is recognized as a python package - # for python.buildEnv - pythonPath = []; - meta = { description = "Python DBus bindings"; - license = stdenv.lib.licenses.mit; + license = lib.licenses.mit; platforms = dbus.meta.platforms; }; } diff --git a/pkgs/development/python-modules/pycairo/default.nix b/pkgs/development/python-modules/pycairo/default.nix index 433eb9d6b2a..fb95a9fa468 100644 --- a/pkgs/development/python-modules/pycairo/default.nix +++ b/pkgs/development/python-modules/pycairo/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchurl, fetchpatch, python, pkgconfig, cairo, xlibsWrapper, isPyPy, isPy35 }: +{ lib, fetchurl, fetchpatch, python, mkPythonDerivation, pkgconfig, cairo, xlibsWrapper, isPyPy, isPy35 }: -if (isPyPy) then throw "pycairo not supported for interpreter ${python.executable}" else stdenv.mkDerivation rec { +if (isPyPy) then throw "pycairo not supported for interpreter ${python.executable}" else mkPythonDerivation rec { version = "1.10.0"; name = "${python.libPrefix}-pycairo-${version}"; src = if python.is_py3k or false @@ -32,7 +32,7 @@ if (isPyPy) then throw "pycairo not supported for interpreter ${python.executabl cd $(${python.executable} waf unpack) pwd patch -p1 < ${patch_waf} - ${stdenv.lib.optionalString isPy35 "patch -p1 < ${patch_waf-py3_5}"} + ${lib.optionalString isPy35 "patch -p1 < ${patch_waf-py3_5}"} ) ${python.executable} waf configure --prefix=$out @@ -40,5 +40,5 @@ if (isPyPy) then throw "pycairo not supported for interpreter ${python.executabl buildPhase = "${python.executable} waf"; installPhase = "${python.executable} waf install"; - meta.platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; + meta.platforms = lib.platforms.linux ++ lib.platforms.darwin; } diff --git a/pkgs/development/python-modules/pygobject/3.nix b/pkgs/development/python-modules/pygobject/3.nix index a6a4d367f1f..43882476b9d 100644 --- a/pkgs/development/python-modules/pygobject/3.nix +++ b/pkgs/development/python-modules/pygobject/3.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchurl, python, pkgconfig, glib, gobjectIntrospection, pycairo, cairo }: +{ lib, fetchurl, mkPythonDerivation, python, pkgconfig, glib, gobjectIntrospection, pycairo, cairo }: -stdenv.mkDerivation rec { +mkPythonDerivation rec { major = "3.20"; minor = "0"; name = "pygobject-${major}.${minor}"; @@ -10,14 +10,12 @@ stdenv.mkDerivation rec { sha256 = "0ikzh3l7g1gjh8jj8vg6mdvrb25svp63gxcam4m0i404yh0lgari"; }; - buildInputs = [ python pkgconfig glib gobjectIntrospection ]; + buildInputs = [ pkgconfig glib gobjectIntrospection ]; propagatedBuildInputs = [ pycairo cairo ]; - passthru.pythonPath = []; - meta = { homepage = http://live.gnome.org/PyGObject; description = "Python bindings for Glib"; - platforms = stdenv.lib.platforms.unix; + platforms = lib.platforms.unix; }; } diff --git a/pkgs/development/python-modules/pygobject/default.nix b/pkgs/development/python-modules/pygobject/default.nix index 3faba55d6a8..5c9367a1f46 100644 --- a/pkgs/development/python-modules/pygobject/default.nix +++ b/pkgs/development/python-modules/pygobject/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchurl, python, pkgconfig, glib }: +{ stdenv, fetchurl, python, mkPythonDerivation, pkgconfig, glib }: -stdenv.mkDerivation rec { +mkPythonDerivation rec { name = "pygobject-2.28.6"; src = fetchurl { @@ -18,9 +18,7 @@ stdenv.mkDerivation rec { configureFlags = "--disable-introspection"; - buildInputs = [ python pkgconfig glib ]; - - passthru.pythonPath = []; + buildInputs = [ pkgconfig glib ]; # in a "normal" setup, pygobject and pygtk are installed into the # same site-packages: we need a pth file for both. pygtk.py would be diff --git a/pkgs/development/python-modules/pygtksourceview/default.nix b/pkgs/development/python-modules/pygtksourceview/default.nix index 48019c62f3e..1c248251a32 100644 --- a/pkgs/development/python-modules/pygtksourceview/default.nix +++ b/pkgs/development/python-modules/pygtksourceview/default.nix @@ -1,8 +1,8 @@ -{ stdenv, fetchurl, python, pkgconfig, pygobject, glib, pygtk, gnome2 }: +{ lib, fetchurl, python, mkPythonDerivation, pkgconfig, pygobject, glib, pygtk, gnome2 }: let version = "2.10.1"; in -stdenv.mkDerivation { +mkPythonDerivation { name = "pygtksourceview-${version}"; src = fetchurl { @@ -15,6 +15,6 @@ stdenv.mkDerivation { buildInputs = [ python pkgconfig pygobject glib pygtk gnome2.gtksourceview ]; meta = { - platforms = stdenv.lib.platforms.unix; + platforms = lib.platforms.unix; }; } diff --git a/pkgs/development/python-modules/pyqt/4.x.nix b/pkgs/development/python-modules/pyqt/4.x.nix index 0eefce47e96..d335ce7b264 100644 --- a/pkgs/development/python-modules/pyqt/4.x.nix +++ b/pkgs/development/python-modules/pyqt/4.x.nix @@ -1,10 +1,10 @@ -{ stdenv, fetchurl, pythonPackages, qt4, pkgconfig, lndir, dbus_libs, makeWrapper }: +{ lib, fetchurl, pythonPackages, qt4, pkgconfig, lndir, dbus_libs, makeWrapper }: let version = "4.11.3"; - inherit (pythonPackages) python dbus-python sip; -in stdenv.mkDerivation { - name = "${python.libPrefix}-PyQt-x11-gpl-${version}"; + inherit (pythonPackages) mkPythonDerivation python dbus-python sip; +in mkPythonDerivation { + name = "$PyQt-x11-gpl-${version}"; src = fetchurl { url = "mirror://sourceforge/pyqt/PyQt4/PyQt-${version}/PyQt-x11-gpl-${version}.tar.gz"; @@ -31,7 +31,7 @@ in stdenv.mkDerivation { buildInputs = [ pkgconfig makeWrapper qt4 lndir dbus_libs ]; - propagatedBuildInputs = [ sip python ]; + propagatedBuildInputs = [ sip ]; postInstall = '' for i in $out/bin/*; do @@ -42,7 +42,6 @@ in stdenv.mkDerivation { enableParallelBuilding = true; passthru = { - pythonPath = []; qt = qt4; }; @@ -50,7 +49,7 @@ in stdenv.mkDerivation { description = "Python bindings for Qt"; license = "GPL"; homepage = http://www.riverbankcomputing.co.uk; - maintainers = [ stdenv.lib.maintainers.sander ]; - platforms = stdenv.lib.platforms.mesaPlatforms; + maintainers = [ lib.maintainers.sander ]; + platforms = lib.platforms.mesaPlatforms; }; } diff --git a/pkgs/development/python-modules/pyqt/5.x.nix b/pkgs/development/python-modules/pyqt/5.x.nix index f5ee50a7352..2b54308e3f0 100644 --- a/pkgs/development/python-modules/pyqt/5.x.nix +++ b/pkgs/development/python-modules/pyqt/5.x.nix @@ -1,13 +1,13 @@ -{ stdenv, fetchurl, pythonPackages, pkgconfig, qtbase, qtsvg, qtwebkit, dbus_libs +{ lib, fetchurl, pythonPackages, pkgconfig, qtbase, qtsvg, qtwebkit, dbus_libs , lndir, makeWrapper, qmakeHook }: let version = "5.6"; - inherit (pythonPackages) python dbus-python sip; -in stdenv.mkDerivation { - name = "${python.libPrefix}-PyQt-${version}"; + inherit (pythonPackages) mkPythonDerivation python dbus-python sip; +in mkPythonDerivation { + name = "PyQt-${version}"; - meta = with stdenv.lib; { + meta = with lib; { description = "Python bindings for Qt5"; homepage = http://www.riverbankcomputing.co.uk; license = licenses.gpl3; @@ -25,7 +25,7 @@ in stdenv.mkDerivation { qtbase qtsvg qtwebkit dbus_libs qmakeHook ]; - propagatedBuildInputs = [ sip python ]; + propagatedBuildInputs = [ sip ]; configurePhase = '' runHook preConfigure @@ -60,6 +60,4 @@ in stdenv.mkDerivation { ''; enableParallelBuilding = true; - - passthru.pythonPath = []; } diff --git a/pkgs/development/python-modules/pyside/default.nix b/pkgs/development/python-modules/pyside/default.nix index fc009a208b7..0bebcf60b53 100644 --- a/pkgs/development/python-modules/pyside/default.nix +++ b/pkgs/development/python-modules/pyside/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, cmake, python, pysideGeneratorrunner, pysideShiboken, qt4 }: -stdenv.mkDerivation rec { +stdenv.mkPythonDerivation rec { name = "${python.libPrefix}-pyside-${version}"; version = "1.2.4"; diff --git a/pkgs/development/python-modules/pyxml/default.nix b/pkgs/development/python-modules/pyxml/default.nix index 3c36565b526..abea143d11d 100644 --- a/pkgs/development/python-modules/pyxml/default.nix +++ b/pkgs/development/python-modules/pyxml/default.nix @@ -1,22 +1,21 @@ -{stdenv, fetchurl, python, makeWrapper}: +{lib, fetchurl, python, mkPythonDerivation, makeWrapper}: -stdenv.mkDerivation rec { +mkPythonDerivation rec { name = "PyXML-0.8.4"; src = fetchurl { url = "mirror://sourceforge/pyxml/${name}.tar.gz"; sha256 = "04wc8i7cdkibhrldy6j65qp5l75zjxf5lx6qxdxfdf2gb3wndawz"; }; - buildInputs = [python makeWrapper]; - buildPhase = "python ./setup.py build"; + buildInputs = [ makeWrapper ]; + buildPhase = "${python.interpreter} ./setup.py build"; installPhase = '' - python ./setup.py install --prefix="$out" || exit 1 + ${python.interpreter} ./setup.py install --prefix="$out" || exit 1 for i in "$out/bin/"* do - # FIXME: We're assuming Python 2.4. wrapProgram "$i" --prefix PYTHONPATH : \ - "$out/lib/python2.4/site-packages" || \ + "$out/${python.sitePackages}" || \ exit 2 done ''; diff --git a/pkgs/development/python-modules/sip/default.nix b/pkgs/development/python-modules/sip/default.nix index cbee1867cf6..e44f92ab013 100644 --- a/pkgs/development/python-modules/sip/default.nix +++ b/pkgs/development/python-modules/sip/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchurl, python, isPyPy }: +{ lib, fetchurl, mkPythonDerivation, python, isPyPy }: -if isPyPy then throw "sip not supported for interpreter ${python.executable}" else stdenv.mkDerivation rec { +if isPyPy then throw "sip not supported for interpreter ${python.executable}" else mkPythonDerivation rec { name = "sip-4.18.1"; src = fetchurl { @@ -14,11 +14,7 @@ if isPyPy then throw "sip not supported for interpreter ${python.executable}" el -b $out/bin -e $out/include ''; - buildInputs = [ python ]; - - passthru.pythonPath = []; - - meta = with stdenv.lib; { + meta = with lib; { description = "Creates C++ bindings for Python modules"; homepage = "http://www.riverbankcomputing.co.uk/"; license = licenses.gpl2Plus; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 867edd0805e..4236b711af7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -20192,7 +20192,7 @@ in modules // { }); - pysvn = pkgs.stdenv.mkDerivation rec { + pysvn = mkPythonDerivation rec { name = "pysvn-1.8.0"; src = pkgs.fetchurl { @@ -20200,7 +20200,7 @@ in modules // { sha256 = "0srjr2qgxfs69p65d9vvdib2lc142x10w8afbbdrqs7dhi46yn9r"; }; - buildInputs = with self; [ python pkgs.subversion pkgs.apr pkgs.aprutil pkgs.expat pkgs.neon pkgs.openssl ] + buildInputs = with self; [ pkgs.subversion pkgs.apr pkgs.aprutil pkgs.expat pkgs.neon pkgs.openssl ] ++ (if stdenv.isLinux then [pkgs.e2fsprogs] else []); # There seems to be no way to pass that path to configure. @@ -20346,7 +20346,7 @@ in modules // { }); - pywebkitgtk = stdenv.mkDerivation rec { + pywebkitgtk = mkPythonDerivation rec { name = "pywebkitgtk-${version}"; version = "1.1.8"; @@ -20677,14 +20677,14 @@ in modules // { qscintilla = if isPy3k || isPyPy then throw "qscintilla-${pkgs.qscintilla.version} not supported for interpreter ${python.executable}" - else pkgs.stdenv.mkDerivation rec { + else mkPythonDerivation rec { # TODO: Qt5 support name = "qscintilla-${version}"; version = pkgs.qscintilla.version; src = pkgs.qscintilla.src; - buildInputs = with self; [ pkgs.xorg.lndir pyqt4.qt pyqt4 python ]; + buildInputs = with self; [ pkgs.xorg.lndir pyqt4.qt pyqt4 ]; preConfigure = '' mkdir -p $out From 9a851907a88ea0bdbfaafb30dbe7588d92af6dd5 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Thu, 1 Sep 2016 15:03:25 +0200 Subject: [PATCH 6/6] pythonPackages.setuptools: 19.4 -> 26.1.1 --- .../development/python-modules/bootstrapped-pip/default.nix | 4 ++-- pkgs/development/python-modules/setuptools/default.nix | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix index f510c5c884b..31436d0ea38 100644 --- a/pkgs/development/python-modules/bootstrapped-pip/default.nix +++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix @@ -6,8 +6,8 @@ let sha256 = "ea8033fc9905804e652f75474d33410a07404c1a78dd3c949a66863bd1050ebd"; }; setuptools_source = fetchurl { - url = "https://pypi.python.org/packages/3.5/s/setuptools/setuptools-19.4-py2.py3-none-any.whl"; - sha256 = "0801e6d862ca4ce24d918420d62f07ee2fe736dc016e3afa99d2103e7a02e9a6"; + url = "https://files.pythonhosted.org/packages/3b/c7/e9724e6f81c96248fba5876054418c11d327b3093d075790903cd66fad44/setuptools-26.1.1-py2.py3-none-any.whl"; + sha256 = "226c9ce65e76c6069e805982b036f36dc4b227b37dd87fc219aef721ec8604ae"; }; argparse_source = fetchurl { url = "https://pypi.python.org/packages/2.7/a/argparse/argparse-1.4.0-py2.py3-none-any.whl"; diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix index 290b0d98fe0..3a38dee3174 100644 --- a/pkgs/development/python-modules/setuptools/default.nix +++ b/pkgs/development/python-modules/setuptools/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { shortName = "setuptools-${version}"; - name = "${python.executable}-${shortName}"; + name = "${python.libPrefix}-${shortName}"; - version = "19.4"; # 18.4 and up breaks python34Packages.characteristic and many others + version = "26.1.1"; # 18.4 and up breaks python34Packages.characteristic and many others src = fetchurl { url = "mirror://pypi/s/setuptools/${shortName}.tar.gz"; - sha256 = "214bf29933f47cf25e6faa569f710731728a07a19cae91ea64f826051f68a8cf"; + sha256 = "475ce28993d7cb75335942525b9fac79f7431a7f6e8a0079c0f2680641379481"; }; buildInputs = [ python wrapPython ];