summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2021-03-23 10:40:02 +0100
committerFrederik Rietdijk <fridh@fridh.nl>2021-03-23 10:43:45 +0100
commit983c453eec9d45cebcf898cf33d87c6fc78e05ad (patch)
treeb8901847a145f4bd8db686700f58a1bb5f39baa7
parent252ae444165fe4be8c8b3e3fc42a1c4eb857d609 (diff)
downloadnixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.tar
nixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.tar.gz
nixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.tar.bz2
nixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.tar.lz
nixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.tar.xz
nixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.tar.zst
nixpkgs-983c453eec9d45cebcf898cf33d87c6fc78e05ad.zip
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.
-rw-r--r--pkgs/development/python-modules/bootstrapped-pip/2.nix67
-rw-r--r--pkgs/development/python-modules/pip/20.nix44
-rw-r--r--pkgs/top-level/python-packages.nix10
3 files changed, 119 insertions, 2 deletions
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 00000000000..5a6333d656a
--- /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 00000000000..6f859d365c5
--- /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 c1b7d8bfb59..a9aa5498ee7 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 { };