python2Packages: keep separate (bootstrapped-)pip

Currently there is only one line difference regarding bootstrapped-pip,
but this will change in the future with the whole Python world moving
towards PEP 517.
This commit is contained in:
Frederik Rietdijk 2021-03-23 10:40:02 +01:00
parent 252ae44416
commit 983c453eec
3 changed files with 119 additions and 2 deletions

View File

@ -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;
};
}

View File

@ -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;
};
}

View File

@ -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 { };