1{ stdenv, python, fetchurl, makeWrapper, unzip }: 2 3let 4 wheel_source = fetchurl { 5 url = "https://pypi.python.org/packages/py2.py3/w/wheel/wheel-0.29.0-py2.py3-none-any.whl"; 6 sha256 = "ea8033fc9905804e652f75474d33410a07404c1a78dd3c949a66863bd1050ebd"; 7 }; 8 setuptools_source = fetchurl { 9 url = "https://pypi.python.org/packages/3.5/s/setuptools/setuptools-19.4-py2.py3-none-any.whl"; 10 sha256 = "0801e6d862ca4ce24d918420d62f07ee2fe736dc016e3afa99d2103e7a02e9a6"; 11 }; 12in stdenv.mkDerivation rec { 13 name = "python-${python.version}-bootstrapped-pip-${version}"; 14 version = "8.0.2"; 15 16 src = fetchurl { 17 url = "https://pypi.python.org/packages/py2.py3/p/pip/pip-${version}-py2.py3-none-any.whl"; 18 sha256 = "249a6f3194be8c2e8cb4d4be3f6fd16a9f1e3336218caffa8e7419e3816f9988"; 19 }; 20 21 unpackPhase = '' 22 mkdir -p $out/${python.sitePackages} 23 unzip -d $out/${python.sitePackages} $src 24 unzip -d $out/${python.sitePackages} ${setuptools_source} 25 unzip -d $out/${python.sitePackages} ${wheel_source} 26 ''; 27 28 patchPhase = '' 29 mkdir -p $out/bin 30 ''; 31 32 buildInputs = [ python makeWrapper unzip ]; 33 34 installPhase = '' 35 36 # install pip binary 37 echo '${python.interpreter} -m pip "$@"' > $out/bin/pip 38 chmod +x $out/bin/pip 39 40 # wrap binaries with PYTHONPATH 41 for f in $out/bin/*; do 42 wrapProgram $f --prefix PYTHONPATH ":" $out/${python.sitePackages}/ 43 done 44 ''; 45}