diff --git a/pkgs/development/python-modules/bootstrapped-pip/2.nix b/pkgs/development/python-modules/bootstrapped-pip/2.nix new file mode 100644 index 000000000000..5a6333d656af --- /dev/null +++ b/pkgs/development/python-modules/bootstrapped-pip/2.nix @@ -0,0 +1,67 @@ +{ lib, stdenv, python, fetchPypi, makeWrapper, unzip, makeSetupHook +, pipInstallHook +, setuptoolsBuildHook +, wheel, pip, setuptools +, isPy27 +}: + +stdenv.mkDerivation rec { + pname = "pip"; + inherit (pip) version; + name = "${python.libPrefix}-bootstrapped-${pname}-${version}"; + + srcs = [ wheel.src pip.src setuptools.src ]; + sourceRoot = "."; + + dontUseSetuptoolsBuild = true; + dontUsePipInstall = true; + + # Should be propagatedNativeBuildInputs + propagatedBuildInputs = [ + # Override to remove dependencies to prevent infinite recursion. + (pipInstallHook.override{pip=null;}) + (setuptoolsBuildHook.override{setuptools=null; wheel=null;}) + ]; + + postPatch = '' + mkdir -p $out/bin + ''; + + nativeBuildInputs = [ makeWrapper unzip ]; + buildInputs = [ python ]; + + buildPhase = ":"; + + installPhase = lib.strings.optionalString (!stdenv.hostPlatform.isWindows) '' + export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0 + '' + '' + # Give folders a known name + mv pip* pip + mv setuptools* setuptools + mv wheel* wheel + # Set up PYTHONPATH. The above folders need to be on PYTHONPATH + # $out is where we are installing to and takes precedence + export PYTHONPATH="$out/${python.sitePackages}:$(pwd)/pip/src:$(pwd)/setuptools:$(pwd)/setuptools/pkg_resources:$(pwd)/wheel:$PYTHONPATH" + + echo "Building setuptools wheel..." + pushd setuptools + ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . + popd + + echo "Building wheel wheel..." + pushd wheel + ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . + popd + + echo "Building pip wheel..." + pushd pip + ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . + popd + ''; + + meta = { + description = "Version of pip used for bootstrapping"; + license = lib.unique (pip.meta.license ++ setuptools.meta.license ++ wheel.meta.license); + homepage = pip.meta.homepage; + }; +} diff --git a/pkgs/development/python-modules/pip/20.nix b/pkgs/development/python-modules/pip/20.nix new file mode 100644 index 000000000000..6f859d365c59 --- /dev/null +++ b/pkgs/development/python-modules/pip/20.nix @@ -0,0 +1,44 @@ +{ lib +, python +, buildPythonPackage +, bootstrapped-pip +, fetchFromGitHub +, mock +, scripttest +, virtualenv +, pretend +, pytest +, setuptools +, wheel +}: + +buildPythonPackage rec { + pname = "pip"; + version = "20.3.4"; + format = "other"; + + src = fetchFromGitHub { + owner = "pypa"; + repo = pname; + rev = version; + sha256 = "0hkhs9yc1cjdj1gn9wkycd3sy65c05q8k8rhqgsm5jbpksfssiwn"; + name = "${pname}-${version}-source"; + }; + + nativeBuildInputs = [ bootstrapped-pip ]; + + # pip detects that we already have bootstrapped_pip "installed", so we need + # to force it a little. + pipInstallFlags = [ "--ignore-installed" ]; + + checkInputs = [ mock scripttest virtualenv pretend pytest ]; + # Pip wants pytest, but tests are not distributed + doCheck = false; + + meta = { + description = "The PyPA recommended tool for installing Python packages"; + license = with lib.licenses; [ mit ]; + homepage = "https://pip.pypa.io/"; + priority = 10; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c1b7d8bfb59d..a9aa5498ee71 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -22,7 +22,10 @@ let namePrefix = python.libPrefix + "-"; - bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { }; + bootstrapped-pip = if isPy3k then + callPackage ../development/python-modules/bootstrapped-pip { } + else + callPackage ../development/python-modules/bootstrapped-pip/2.nix { }; # Derivations built with `buildPythonPackage` can already be overriden with `override`, `overrideAttrs`, and `overrideDerivation`. # This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`. @@ -5122,7 +5125,10 @@ in { pint = callPackage ../development/python-modules/pint { }; - pip = callPackage ../development/python-modules/pip { }; + pip = if isPy3k then + callPackage ../development/python-modules/pip { } + else + callPackage ../development/python-modules/pip/20.nix { }; pipdate = callPackage ../development/python-modules/pipdate { };