summary refs log blame commit diff
path: root/pkgs/development/interpreters/python/build-python-package-common.nix
blob: 0f8e088d434a20d723913ec472a6f3503e999e98 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                                                                







                                            
                                                                               
 
                                             



                         






                                                               
                                                                                                                                                      



                       
 
# 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
  '';
}