about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/python/build-python-package-common.nix
blob: 0f8e088d434a20d723913ec472a6f3503e999e98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# This function provides generic bits to install a Python wheel.

{ python
}:

{ buildInputs ? []
# Additional flags to pass to "pip install".
, installFlags ? []
, ... } @ attrs:

attrs // {
  buildInputs = buildInputs ++ [ python.pythonForBuild.pkgs.bootstrapped-pip ];

  configurePhase = attrs.configurePhase or ''
    runHook preConfigure
    runHook postConfigure
  '';

  installPhase = attrs.installPhase or ''
    runHook preInstall

    mkdir -p "$out/${python.sitePackages}"
    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"

    pushd dist
    ${python.pythonForBuild.pkgs.bootstrapped-pip}/bin/pip install *.whl --no-index --prefix=$out --no-cache ${toString installFlags} --build tmpbuild
    popd

    runHook postInstall
  '';
}