diff -uNr Python-2.6.9.orig/Lib/distutils/tests/test_build_ext.py Python-2.6.9/Lib/distutils/tests/test_build_ext.py --- Python-2.6.9.orig/Lib/distutils/tests/test_build_ext.py 2013-10-29 16:04:37.000000000 +0100 +++ Python-2.6.9/Lib/distutils/tests/test_build_ext.py 2014-06-20 17:14:14.700080398 +0200 @@ -35,6 +35,24 @@ sys.path.append(self.tmp_dir) shutil.copy(_get_source_filename(), self.tmp_dir) + def _fixup_command(self, cmd): + # When Python was build with --enable-shared, -L. is not good enough + # to find the libpython.so. This is because regrtest runs it + # under a tempdir, not in the top level where the .so lives. By the + # time we've gotten here, Python's already been chdir'd to the + # tempdir. + # + # To further add to the fun, we can't just add library_dirs to the + # Extension() instance because that doesn't get plumbed through to the + # final compiler command. + if not sys.platform.startswith('win'): + runshared = sysconfig.get_config_var('RUNSHARED') + if runshared is None: + cmd.library_dirs = ['.'] + else: + name, equals, value = runshared.partition('=') + cmd.library_dirs = value.split(os.pathsep) + def test_build_ext(self): global ALREADY_TESTED xx_c = os.path.join(self.tmp_dir, 'xxmodule.c') @@ -42,6 +60,7 @@ dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]}) dist.package_dir = self.tmp_dir cmd = build_ext(dist) + self._fixup_command(cmd) if os.name == "nt": # On Windows, we must build a debug version iff running # a debug build of Python @@ -242,6 +261,7 @@ dist = Distribution({'name': 'xx', 'ext_modules': [ext]}) cmd = build_ext(dist) + self._fixup_command(cmd) cmd.ensure_finalized() self.assertEquals(len(cmd.get_outputs()), 1)