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