prevent distutils during module install from downloading and load pth files

based on a patch by Cillian de Róiste

svn path=/nixpkgs/branches/stdenv-updates/; revision=32583
This commit is contained in:
Florian Friesdorf
2012-02-26 17:23:09 +00:00
parent ccb34b093f
commit d52e2c7c41
3 changed files with 36 additions and 2 deletions

View File

@@ -3,7 +3,7 @@
(http://pypi.python.org/pypi/setuptools/), which represents a large
number of Python packages nowadays. */
{ python, setuptools, wrapPython, lib, site }:
{ python, setuptools, wrapPython, lib, site, offlineDistutils }:
{ name, namePrefix ? "python-"
@@ -69,6 +69,15 @@ python.stdenv.mkDerivation (attrs // {
buildInputs = [ python wrapPython setuptools ] ++ buildInputs ++ pythonPath;
configurePhase = ''
# do not allow distutils to make downloads, whatever install command is used
export PYTHONPATH="${setuptools}/lib/${python.libPrefix}:$PYTHONPATH"
export PYTHONPATH="${offlineDistutils}/lib/${python.libPrefix}:$PYTHONPATH"
# enable pth files for dependencies
export PYTHONPATH="${site}/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
'';
# XXX: I think setuptools is not needed here
pythonPath = [ setuptools site ] ++ pythonPath;

View File

@@ -0,0 +1,21 @@
# Used during module installation to prevent easy_install and python
# setup.py install/test from downloading
{ stdenv, python }:
stdenv.mkDerivation {
name = "python-offline-distutils-${python.version}";
buildInputs = [ python ];
unpackPhase = "true";
installPhase = ''
dst="$out/lib/${python.libPrefix}"
ensureDir $dst/distutils
ln -s ${python}/lib/${python.libPrefix}/distutils/* $dst/distutils/
cat <<EOF > $dst/distutils/distutils.cfg
[easy_install]
allow-hosts = None
EOF
'';
}