test_distutils fails when you're not building in the root of the source tree. That is: mkdir build cd build ../configure make make check This fails like this: test test_distutils failed -- Traceback (most recent call last): File "/Users/ronald/Projects/python/python- trunk/Lib/distutils/tests/test_build_ext.py", line 23, in setUp shutil.copy(xx_c, self.tmp_dir) File "/Users/ronald/Projects/python/python-trunk/Lib/shutil.py", line 82, in copy copyfile(src, dst) File "/Users/ronald/Projects/python/python-trunk/Lib/shutil.py", line 46, in copyfile fsrc = open(src, 'rb') IOError: [Errno 2] No such file or directory: '/Users/ronald/Projects/python/python-trunk/build104/Modules/xxmodule.c'
This also happens in py3k. Attached a patch that fixes this by using the dirname of sysconfig.project_base if the file is not found, but perhaps a better solution could be found...
Looks like this has exposed some ugly code. From setup.py: # Figure out the location of the source code for extension modules # (This logic is copied in distutils.test.test_sysconfig, # so building in a separate directory does not break test_distutils.) I believe the proper fix is to move some of the code from setup.py into sysconfig so that it does more than just set "python_build" when running inside a Python build directory. For example, it should also add /Include to the standard list of includes that distutils uses. The attached patch fixes test_build_ext.py to use the right source file (perhaps it should be tested on Windows). The test still fails because Python.h cannot be found.
I think my previous patch combined with sysconfig_builddir.patch fixes this issue. Someone will need to test on other platforms. Note that the messy code in setup.py and in the tests should still be cleaned up. BTW, distutils is a den of stinking evil. ;-)
One final patch for today (get_python_inc.patch). The patch combines my previous two patches and also cleans up some ugly code in setup.py and test_sysconfig.py. The source of the ugliness was that get_python_inc() did not work when running from within a build directory. The patch also fixes the header dependency feature introduced in svn r60287 (it assumed that builddir == srcdir and also that os.path.sep == '/').