2017-11-11 07:24:38 -08:00
|
|
|
# This function provides a generic Python package builder,
|
|
|
|
# and can build packages that use distutils, setuptools or flit.
|
2009-05-24 14:02:59 -07:00
|
|
|
|
2016-08-17 05:23:47 -07:00
|
|
|
{ lib
|
2018-04-25 10:15:48 -07:00
|
|
|
, config
|
2016-08-17 05:23:47 -07:00
|
|
|
, python
|
2017-05-28 00:20:47 -07:00
|
|
|
, wrapPython
|
|
|
|
, setuptools
|
|
|
|
, unzip
|
2018-02-13 06:32:16 -08:00
|
|
|
, ensureNewerSourcesForZipFilesHook
|
2017-12-10 05:20:38 -08:00
|
|
|
, toPythonModule
|
2017-05-28 00:20:47 -07:00
|
|
|
, namePrefix
|
2016-12-03 04:04:52 -08:00
|
|
|
, flit
|
2018-11-24 03:56:24 -08:00
|
|
|
, writeScript
|
|
|
|
, update-python-libraries
|
2016-08-17 05:23:47 -07:00
|
|
|
}:
|
2009-05-24 14:02:59 -07:00
|
|
|
|
2016-12-03 04:04:52 -08:00
|
|
|
let
|
2019-01-02 11:09:44 -08:00
|
|
|
setuptools-specific = import ./build-python-package-setuptools.nix { inherit lib python; };
|
2019-02-17 11:33:30 -08:00
|
|
|
pyproject-specific = import ./build-python-package-pyproject.nix { inherit lib python; };
|
2017-02-01 05:26:27 -08:00
|
|
|
flit-specific = import ./build-python-package-flit.nix { inherit python flit; };
|
2016-12-03 04:04:52 -08:00
|
|
|
wheel-specific = import ./build-python-package-wheel.nix { };
|
2019-01-02 11:09:44 -08:00
|
|
|
common = import ./build-python-package-common.nix { inherit python; };
|
2017-05-28 00:20:47 -07:00
|
|
|
mkPythonDerivation = import ./mk-python-derivation.nix {
|
2018-11-24 03:56:24 -08:00
|
|
|
inherit lib config python wrapPython setuptools unzip ensureNewerSourcesForZipFilesHook;
|
2019-06-16 12:59:06 -07:00
|
|
|
inherit toPythonModule namePrefix update-python-libraries;
|
2017-05-28 00:20:47 -07:00
|
|
|
};
|
2016-12-03 04:04:52 -08: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 08:30:48 -07:00
|
|
|
, ... } @ attrs:
|
2009-05-24 14:02:59 -07:00
|
|
|
|
2015-11-17 02:38:26 -08:00
|
|
|
let
|
2016-04-26 08:57:13 -07:00
|
|
|
formatspecific =
|
2019-02-17 11:33:30 -08:00
|
|
|
if format == "pyproject" then common (pyproject-specific attrs)
|
|
|
|
else if format == "setuptools" then common (setuptools-specific attrs)
|
2016-12-03 04:04:52 -08: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 02:06:04 -07:00
|
|
|
|
2017-02-01 05:26:27 -08:00
|
|
|
in mkPythonDerivation ( attrs // formatspecific )
|