1# This function provides a generic Python package builder,
2# and can build packages that use distutils, setuptools or flit.
3
4{ lib
5, python
6, wrapPython
7, setuptools
8, unzip
9, ensureNewerSourcesForZipFilesHook
10, toPythonModule
11, namePrefix
12, bootstrapped-pip
13, flit
14}:
15
16let
17 setuptools-specific = import ./build-python-package-setuptools.nix { inherit lib python bootstrapped-pip; };
18 flit-specific = import ./build-python-package-flit.nix { inherit python flit; };
19 wheel-specific = import ./build-python-package-wheel.nix { };
20 common = import ./build-python-package-common.nix { inherit python bootstrapped-pip; };
21 mkPythonDerivation = import ./mk-python-derivation.nix {
22 inherit lib python wrapPython setuptools unzip ensureNewerSourcesForZipFilesHook toPythonModule namePrefix;
23 };
24in
25
26{
27# Several package formats are supported.
28# "setuptools" : Install a common setuptools/distutils based package. This builds a wheel.
29# "wheel" : Install from a pre-compiled wheel.
30# "flit" : Install a flit package. This builds a wheel.
31# "other" : Provide your own buildPhase and installPhase.
32format ? "setuptools"
33, ... } @ attrs:
34
35let
36 formatspecific =
37 if format == "setuptools" then common (setuptools-specific attrs)
38 else if format == "flit" then common (flit-specific attrs)
39 else if format == "wheel" then common (wheel-specific attrs)
40 else if format == "other" then {}
41 else throw "Unsupported format ${format}";
42
43in mkPythonDerivation ( attrs // formatspecific )