diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2016-08-17 14:23:47 +0200 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2016-09-01 16:16:31 +0200 |
commit | 3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6 (patch) | |
tree | f78004655b20637a5293f8d966e67fd776210201 /pkgs/development/interpreters/python/mk-python-derivation.nix | |
parent | 725c37b4d350c9c040c29efd8146619f77c897f5 (diff) | |
download | nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.tar nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.tar.gz nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.tar.bz2 nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.tar.lz nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.tar.xz nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.tar.zst nixlib-3e05cce97ca3ea9eee42a17c8bc0b89345b5d0b6.zip |
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
Diffstat (limited to 'pkgs/development/interpreters/python/mk-python-derivation.nix')
-rw-r--r-- | pkgs/development/interpreters/python/mk-python-derivation.nix | 87 |
1 files changed, 87 insertions, 0 deletions
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 000000000000..e46f9afde963 --- /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; + }; +}) + + |