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: 42 # - pip and setuptools need to be in PYTHONPATH to install setuptools, wheel, and pip. 43 # - $out is where we are installing to and takes precedence, and is where wheel will end so we can install pip. 44 export PYTHONPATH="$out/${python.sitePackages}:$(pwd)/pip/src:$(pwd)/setuptools:$(pwd)/setuptools/pkg_resources:$PYTHONPATH" 45 46 echo "Building setuptools wheel..." 47 pushd setuptools 48 ${python.pythonOnBuildForHost.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . 49 popd 50 51 echo "Building wheel wheel..." 52 pushd wheel 53 ${python.pythonOnBuildForHost.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . 54 popd 55 56 echo "Building pip wheel..." 57 pushd pip 58 ${python.pythonOnBuildForHost.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . 59 popd 60 ''; 61 62 meta = { 63 description = "Version of pip used for bootstrapping"; 64 license = lib.unique (pip.meta.license ++ setuptools.meta.license ++ wheel.meta.license); 65 homepage = pip.meta.homepage; 66 }; 67}