2017-06-07 16:28:34 +01:00
|
|
|
{ stdenv, python, fetchPypi, fetchurl, makeWrapper, unzip }:
|
2015-11-17 10:38:26 +00:00
|
|
|
|
|
|
|
let
|
2017-06-01 17:20:42 +01:00
|
|
|
wheel_source = fetchPypi {
|
|
|
|
pname = "wheel";
|
2017-09-11 21:48:30 +01:00
|
|
|
version = "0.30.0";
|
2017-06-01 17:20:42 +01:00
|
|
|
format = "wheel";
|
2017-09-11 21:48:30 +01:00
|
|
|
sha256 = "e721e53864f084f956f40f96124a74da0631ac13fbbd1ba99e8e2b5e9cafdf64";
|
2015-11-17 10:38:26 +00:00
|
|
|
};
|
2017-06-01 17:20:42 +01:00
|
|
|
setuptools_source = fetchPypi {
|
|
|
|
pname = "setuptools";
|
2018-04-08 07:46:36 +01:00
|
|
|
version = "39.0.1";
|
2017-06-01 17:20:42 +01:00
|
|
|
format = "wheel";
|
2018-04-08 07:46:36 +01:00
|
|
|
sha256 = "8010754433e3211b9cdbbf784b50f30e80bf40fc6b05eb5f865fab83300599b8";
|
2015-11-17 10:38:26 +00:00
|
|
|
};
|
2017-06-07 16:28:34 +01:00
|
|
|
|
2018-04-08 07:46:36 +01:00
|
|
|
# TODO: Shouldn't be necessary anymore for pip >= 10!
|
2017-06-07 16:28:34 +01:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/26392
|
|
|
|
# https://github.com/pypa/setuptools/issues/885
|
|
|
|
pkg_resources = fetchurl {
|
2017-10-07 11:56:36 +01:00
|
|
|
url = "https://raw.githubusercontent.com/pypa/setuptools/v36.0.1/pkg_resources/__init__.py";
|
2017-06-07 16:28:34 +01:00
|
|
|
sha256 = "1wdnq3mammk75mifkdmmjx7yhnpydvnvi804na8ym4mj934l2jkv";
|
|
|
|
};
|
|
|
|
|
2015-11-17 10:38:26 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2017-06-01 17:20:42 +01:00
|
|
|
pname = "pip";
|
2018-04-14 16:11:50 +01:00
|
|
|
version = "10.0.1";
|
2017-06-01 17:20:42 +01:00
|
|
|
name = "${python.libPrefix}-bootstrapped-${pname}-${version}";
|
2015-11-17 10:38:26 +00:00
|
|
|
|
2017-06-01 17:20:42 +01:00
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
|
|
|
format = "wheel";
|
2018-04-14 16:11:50 +01:00
|
|
|
sha256 = "717cdffb2833be8409433a93746744b59505f42146e8d37de6c62b430e25d6d7";
|
2015-11-17 10:38:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
mkdir -p $out/${python.sitePackages}
|
|
|
|
unzip -d $out/${python.sitePackages} $src
|
|
|
|
unzip -d $out/${python.sitePackages} ${setuptools_source}
|
|
|
|
unzip -d $out/${python.sitePackages} ${wheel_source}
|
2018-04-08 07:46:36 +01:00
|
|
|
# TODO: Shouldn't be necessary anymore for pip >= 10!
|
2017-06-07 16:28:34 +01:00
|
|
|
cp ${pkg_resources} $out/${python.sitePackages}/pip/_vendor/pkg_resources/__init__.py
|
2015-11-17 10:38:26 +00:00
|
|
|
'';
|
|
|
|
|
2015-11-18 10:44:37 +00:00
|
|
|
patchPhase = ''
|
2015-11-17 10:38:26 +00:00
|
|
|
mkdir -p $out/bin
|
2015-11-18 10:44:37 +00:00
|
|
|
'';
|
|
|
|
|
2018-01-11 17:27:04 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper unzip ];
|
|
|
|
buildInputs = [ python ];
|
2015-11-18 10:44:37 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2015-11-17 10:38:26 +00:00
|
|
|
|
|
|
|
# install pip binary
|
2016-03-24 15:44:14 +00:00
|
|
|
echo '#!${python.interpreter}' > $out/bin/pip
|
2018-04-14 16:11:50 +01:00
|
|
|
echo 'import sys;from pip._internal import main' >> $out/bin/pip
|
2016-03-24 15:44:14 +00:00
|
|
|
echo 'sys.exit(main())' >> $out/bin/pip
|
2015-11-17 10:38:26 +00:00
|
|
|
chmod +x $out/bin/pip
|
|
|
|
|
|
|
|
# wrap binaries with PYTHONPATH
|
|
|
|
for f in $out/bin/*; do
|
|
|
|
wrapProgram $f --prefix PYTHONPATH ":" $out/${python.sitePackages}/
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
}
|