3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/python-modules/bootstrapped-pip/default.nix

66 lines
1.9 KiB
Nix
Raw Normal View History

{ stdenv, python, fetchPypi, fetchurl, makeWrapper, unzip }:
let
wheel_source = fetchPypi {
pname = "wheel";
2017-09-11 21:48:30 +01:00
version = "0.30.0";
format = "wheel";
2017-09-11 21:48:30 +01:00
sha256 = "e721e53864f084f956f40f96124a74da0631ac13fbbd1ba99e8e2b5e9cafdf64";
};
setuptools_source = fetchPypi {
pname = "setuptools";
version = "38.4.0";
format = "wheel";
sha256 = "155c2ec9fdcc00c3973d966b416e1cf3a1e7ce75f4c09fb760b23f94b935926e";
};
# TODO: Shouldn't be necessary anymore for pip > 9.0.1!
# https://github.com/NixOS/nixpkgs/issues/26392
# https://github.com/pypa/setuptools/issues/885
pkg_resources = fetchurl {
url = "https://raw.githubusercontent.com/pypa/setuptools/v36.0.1/pkg_resources/__init__.py";
sha256 = "1wdnq3mammk75mifkdmmjx7yhnpydvnvi804na8ym4mj934l2jkv";
};
in stdenv.mkDerivation rec {
pname = "pip";
2016-11-14 20:58:53 +00:00
version = "9.0.1";
name = "${python.libPrefix}-bootstrapped-${pname}-${version}";
src = fetchPypi {
inherit pname version;
format = "wheel";
2016-11-14 20:58:53 +00:00
sha256 = "690b762c0a8460c303c089d5d0be034fb15a5ea2b75bdf565f40421f542fefb0";
};
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}
# TODO: Shouldn't be necessary anymore for pip > 9.0.1!
cp ${pkg_resources} $out/${python.sitePackages}/pip/_vendor/pkg_resources/__init__.py
'';
patchPhase = ''
mkdir -p $out/bin
'';
nativeBuildInputs = [ makeWrapper unzip ];
buildInputs = [ python ];
installPhase = ''
# install pip binary
2016-03-24 15:44:14 +00:00
echo '#!${python.interpreter}' > $out/bin/pip
echo 'import sys;from pip import main' >> $out/bin/pip
echo 'sys.exit(main())' >> $out/bin/pip
chmod +x $out/bin/pip
# wrap binaries with PYTHONPATH
for f in $out/bin/*; do
wrapProgram $f --prefix PYTHONPATH ":" $out/${python.sitePackages}/
done
'';
}