Refactor buildPythonPackage to modularize building process.

Before we used `easy_install` command to handle installation
in one shot, now this is split into two phases:

 - buildPhase: python setup.py build
 - installPhase: python setup.py install

Each of those commands have the ability to pass extra
parameters through buildPythonPackage parameters as
`setupPyInstallFlags` and `setupPyBuildFlags`.

Phases now correctly execute post/pre hooks.

In configurePhase we inject setuptools dependency before distutils
is imported to apply monkeypatching by setuptools that is needed
for special features to apply.

We don't have to reorder default phases anymore, as test
phase comes after build and that works.

I rewrote offineDistutils into distutils-cfg with a bit cleaner
syntax and ability to specify extraCfg to the config file.

Plone packages are failing and garbas said he will adopt them to
the new functions. The rest of the packages I fixed and these commits
shouldn't break any package (according to my testings) and they introduce
16 new jobs and fix 38 that were broken before.
This commit is contained in:
Domen Kožar
2014-01-06 22:24:05 +00:00
parent e9923c6499
commit bf5d6fb9b1
4 changed files with 106 additions and 80 deletions

View File

@@ -0,0 +1,31 @@
# global distutils configuration, see http://docs.python.org/2/install/index.html#distutils-configuration-files
{ stdenv, python, writeText, extraCfg ? "" }:
let
distutilsCfg = writeText "distutils.cfg" ''
[easy_install]
# don't allow network connections during build to ensure purity
allow-hosts = None
# make sure we always unzip installed packages otherwise setup hooks won't work
zip_ok = 0
${extraCfg}
'';
in stdenv.mkDerivation {
name = "distutils.cfg-python${python.version}";
buildInputs = [ python ];
unpackPhase = "true";
installPhase = ''
dest="$out/lib/${python.libPrefix}/site-packages/distutils"
mkdir -p $dest
ln -s ${python}/lib/${python.libPrefix}/distutils/* $dest
ln -s ${distutilsCfg} $dest/distutils.cfg
'';
}