2017-11-11 16:24:38 +01:00
|
|
|
# This function provides a generic Python package builder,
|
|
|
|
# and can build packages that use distutils, setuptools or flit.
|
2009-05-24 23:02:59 +02:00
|
|
|
|
2016-08-17 14:23:47 +02:00
|
|
|
{ lib
|
2018-04-25 19:15:48 +02:00
|
|
|
, config
|
2016-08-17 14:23:47 +02:00
|
|
|
, python
|
2017-05-28 09:20:47 +02:00
|
|
|
, wrapPython
|
|
|
|
, setuptools
|
|
|
|
, unzip
|
2018-02-13 15:32:16 +01:00
|
|
|
, ensureNewerSourcesForZipFilesHook
|
2017-12-10 14:20:38 +01:00
|
|
|
, toPythonModule
|
2017-05-28 09:20:47 +02:00
|
|
|
, namePrefix
|
2016-12-03 13:04:52 +01:00
|
|
|
, flit
|
2018-11-24 12:56:24 +01:00
|
|
|
, writeScript
|
|
|
|
, update-python-libraries
|
2016-08-17 14:23:47 +02:00
|
|
|
}:
|
2009-05-24 23:02:59 +02:00
|
|
|
|
2016-12-03 13:04:52 +01:00
|
|
|
let
|
2019-01-02 20:09:44 +01:00
|
|
|
setuptools-specific = import ./build-python-package-setuptools.nix { inherit lib python; };
|
2019-02-17 20:33:30 +01:00
|
|
|
pyproject-specific = import ./build-python-package-pyproject.nix { inherit lib python; };
|
2017-02-01 14:26:27 +01:00
|
|
|
flit-specific = import ./build-python-package-flit.nix { inherit python flit; };
|
2016-12-03 13:04:52 +01:00
|
|
|
wheel-specific = import ./build-python-package-wheel.nix { };
|
2019-01-02 20:09:44 +01:00
|
|
|
common = import ./build-python-package-common.nix { inherit python; };
|
2017-05-28 09:20:47 +02:00
|
|
|
mkPythonDerivation = import ./mk-python-derivation.nix {
|
2018-11-24 12:56:24 +01:00
|
|
|
inherit lib config python wrapPython setuptools unzip ensureNewerSourcesForZipFilesHook;
|
|
|
|
inherit toPythonModule namePrefix writeScript update-python-libraries;
|
2017-05-28 09:20:47 +02:00
|
|
|
};
|
2016-12-03 13:04:52 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
# Several package formats are supported.
|
|
|
|
# "setuptools" : Install a common setuptools/distutils based package. This builds a wheel.
|
|
|
|
# "wheel" : Install from a pre-compiled wheel.
|
|
|
|
# "flit" : Install a flit package. This builds a wheel.
|
|
|
|
# "other" : Provide your own buildPhase and installPhase.
|
|
|
|
format ? "setuptools"
|
2011-03-28 17:30:48 +02:00
|
|
|
, ... } @ attrs:
|
2009-05-24 23:02:59 +02:00
|
|
|
|
2015-11-17 11:38:26 +01:00
|
|
|
let
|
2016-04-26 17:57:13 +02:00
|
|
|
formatspecific =
|
2019-02-17 20:33:30 +01:00
|
|
|
if format == "pyproject" then common (pyproject-specific attrs)
|
|
|
|
else if format == "setuptools" then common (setuptools-specific attrs)
|
2016-12-03 13:04:52 +01:00
|
|
|
else if format == "flit" then common (flit-specific attrs)
|
|
|
|
else if format == "wheel" then common (wheel-specific attrs)
|
|
|
|
else if format == "other" then {}
|
|
|
|
else throw "Unsupported format ${format}";
|
2014-03-10 10:06:04 +01:00
|
|
|
|
2017-02-01 14:26:27 +01:00
|
|
|
in mkPythonDerivation ( attrs // formatspecific )
|