2019-07-17 19:36:47 +01:00
|
|
|
{ stdenv, python, fetchPypi, makeWrapper, unzip, makeSetupHook
|
|
|
|
, pipInstallHook
|
|
|
|
, setuptoolsBuildHook
|
|
|
|
|
|
|
|
}:
|
2015-11-17 10:38:26 +00:00
|
|
|
|
|
|
|
let
|
2017-06-01 17:20:42 +01:00
|
|
|
wheel_source = fetchPypi {
|
|
|
|
pname = "wheel";
|
2019-08-31 14:22:52 +01:00
|
|
|
version = "0.33.6";
|
2017-06-01 17:20:42 +01:00
|
|
|
format = "wheel";
|
2019-08-31 14:22:52 +01:00
|
|
|
sha256 = "f4da1763d3becf2e2cd92a14a7c920f0f00eca30fdde9ea992c836685b9faf28";
|
2015-11-17 10:38:26 +00:00
|
|
|
};
|
2017-06-01 17:20:42 +01:00
|
|
|
setuptools_source = fetchPypi {
|
|
|
|
pname = "setuptools";
|
2019-10-16 10:23:01 +01:00
|
|
|
version = "41.4.0";
|
2017-06-01 17:20:42 +01:00
|
|
|
format = "wheel";
|
2019-10-16 10:23:01 +01:00
|
|
|
sha256 = "8d01f7ee4191d9fdcd9cc5796f75199deccb25b154eba82d44d6a042cf873670";
|
2015-11-17 10:38:26 +00:00
|
|
|
};
|
2017-06-07 16:28:34 +01:00
|
|
|
|
2015-11-17 10:38:26 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2017-06-01 17:20:42 +01:00
|
|
|
pname = "pip";
|
2019-10-18 11:41:53 +01:00
|
|
|
version = "19.3.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";
|
2019-10-18 11:41:53 +01:00
|
|
|
sha256 = "6917c65fc3769ecdc61405d3dfd97afdedd75808d200b2838d7d961cebc0c2c7";
|
2015-11-17 10:38:26 +00:00
|
|
|
};
|
|
|
|
|
2019-07-17 19:36:47 +01:00
|
|
|
dontUseSetuptoolsBuild = true;
|
|
|
|
|
|
|
|
# Should be propagatedNativeBuildInputs
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
# Override to remove dependencies to prevent infinite recursion.
|
|
|
|
(pipInstallHook.override{pip=null;})
|
|
|
|
(setuptoolsBuildHook.override{setuptools=null; wheel=null;})
|
|
|
|
];
|
|
|
|
|
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}
|
|
|
|
'';
|
|
|
|
|
2019-07-17 19:36:47 +01:00
|
|
|
postPatch = ''
|
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
|
|
|
|
'';
|
2019-07-17 19:36:47 +01:00
|
|
|
|
2015-11-17 10:38:26 +00:00
|
|
|
}
|