Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-19.03 48 lines 1.7 kB view raw
1# This function provides a generic Python package builder, 2# and can build packages that use distutils, setuptools or flit. 3 4{ lib 5, config 6, python 7, wrapPython 8, setuptools 9, unzip 10, ensureNewerSourcesForZipFilesHook 11, toPythonModule 12, namePrefix 13, flit 14, writeScript 15, update-python-libraries 16}: 17 18let 19 setuptools-specific = import ./build-python-package-setuptools.nix { inherit lib python; }; 20 pyproject-specific = import ./build-python-package-pyproject.nix { inherit lib python; }; 21 flit-specific = import ./build-python-package-flit.nix { inherit python flit; }; 22 wheel-specific = import ./build-python-package-wheel.nix { }; 23 common = import ./build-python-package-common.nix { inherit python; }; 24 mkPythonDerivation = import ./mk-python-derivation.nix { 25 inherit lib config python wrapPython setuptools unzip ensureNewerSourcesForZipFilesHook; 26 inherit toPythonModule namePrefix writeScript update-python-libraries; 27 }; 28in 29 30{ 31# Several package formats are supported. 32# "setuptools" : Install a common setuptools/distutils based package. This builds a wheel. 33# "wheel" : Install from a pre-compiled wheel. 34# "flit" : Install a flit package. This builds a wheel. 35# "other" : Provide your own buildPhase and installPhase. 36format ? "setuptools" 37, ... } @ attrs: 38 39let 40 formatspecific = 41 if format == "pyproject" then common (pyproject-specific attrs) 42 else if format == "setuptools" then common (setuptools-specific attrs) 43 else if format == "flit" then common (flit-specific attrs) 44 else if format == "wheel" then common (wheel-specific attrs) 45 else if format == "other" then {} 46 else throw "Unsupported format ${format}"; 47 48in mkPythonDerivation ( attrs // formatspecific )