1{ lib, stdenv, python, fetchPypi, makeWrapper, unzip, makeSetupHook
2, pipInstallHook
3, setuptoolsBuildHook
4, wheel, pip, setuptools
5, isPy27
6}:
7
8stdenv.mkDerivation rec {
9 pname = "pip";
10 inherit (pip) version;
11 name = "${python.libPrefix}-bootstrapped-${pname}-${version}";
12
13 srcs = [ wheel.src pip.src setuptools.src ];
14 sourceRoot = ".";
15
16 dontUseSetuptoolsBuild = true;
17 dontUsePipInstall = true;
18
19 # Should be propagatedNativeBuildInputs
20 propagatedBuildInputs = [
21 # Override to remove dependencies to prevent infinite recursion.
22 (pipInstallHook.override{pip=null;})
23 (setuptoolsBuildHook.override{setuptools=null; wheel=null;})
24 ];
25
26 postPatch = ''
27 mkdir -p $out/bin
28 '';
29
30 nativeBuildInputs = [ makeWrapper unzip ];
31 buildInputs = [ python ];
32
33 buildPhase = ":";
34
35 installPhase = lib.strings.optionalString (!stdenv.hostPlatform.isWindows) ''
36 export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0
37 '' + ''
38 # Give folders a known name
39 mv pip* pip
40 mv setuptools* setuptools
41 mv wheel* wheel
42 # Set up PYTHONPATH. The above folders need to be on PYTHONPATH
43 # $out is where we are installing to and takes precedence
44 export PYTHONPATH="$out/${python.sitePackages}:$(pwd)/pip/src:$(pwd)/setuptools:$(pwd)/setuptools/pkg_resources:$(pwd)/wheel:$PYTHONPATH"
45
46 echo "Building setuptools wheel..."
47 pushd setuptools
48 rm pyproject.toml
49 ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache .
50 popd
51
52 echo "Building wheel wheel..."
53 pushd wheel
54 ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache .
55 popd
56
57 echo "Building pip wheel..."
58 pushd pip
59 ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache .
60 popd
61 '';
62
63 meta = {
64 description = "Version of pip used for bootstrapping";
65 license = lib.unique (pip.meta.license ++ setuptools.meta.license ++ wheel.meta.license);
66 homepage = pip.meta.homepage;
67 };
68}