summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-08-21 15:10:50 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-08-21 15:10:50 (GMT)
commit006b4855111417bc0adf54be4109f9686003cacf (patch)
tree219df85bd4f258e020453985826d582061392c5f /Lib/distutils/tests
parent7dfb3a1993ac2a1a04e9347b7c5a8f7f57cefd78 (diff)
parent8c973189b59ffd49ec5204e0afc3afed4654c7c8 (diff)
downloadcpython-006b4855111417bc0adf54be4109f9686003cacf.zip
cpython-006b4855111417bc0adf54be4109f9686003cacf.tar.gz
cpython-006b4855111417bc0adf54be4109f9686003cacf.tar.bz2
Merge build_ext fix from 3.2
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/support.py27
-rw-r--r--Lib/distutils/tests/test_build_ext.py31
-rw-r--r--Lib/distutils/tests/test_install.py1
3 files changed, 34 insertions, 25 deletions
diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py
index 4927711..ffef98b 100644
--- a/Lib/distutils/tests/support.py
+++ b/Lib/distutils/tests/support.py
@@ -1,5 +1,6 @@
"""Support code for distutils test cases."""
import os
+import sys
import shutil
import tempfile
import unittest
@@ -165,3 +166,29 @@ def _get_xxmodule_path():
for path in candidates:
if os.path.exists(path):
return path
+
+
+def fixup_build_ext(cmd):
+ """Function needed to make build_ext tests pass on shared builds.
+
+ When Python was build with --enable-shared, -L. is not good enough to find
+ the libpython<blah>.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. This function work arounds
+ that. Example use:
+
+ cmd = build_ext(dist)
+ support.fixup_build_ext(cmd)
+ cmd.ensure_finalized()
+ """
+ # 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 (sysconfig.get_config_var('Py_ENABLE_SHARED') and
+ 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)
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index de53afb..8eb59b4 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -7,7 +7,7 @@ from distutils.core import Distribution
from distutils.command.build_ext import build_ext
from distutils import sysconfig
from distutils.tests.support import (TempdirManager, LoggingSilencer,
- copy_xxmodule_c)
+ copy_xxmodule_c, fixup_build_ext)
from distutils.extension import Extension
from distutils.errors import (
CompileError, DistutilsPlatformError, DistutilsSetupError,
@@ -38,25 +38,6 @@ class BuildExtTestCase(TempdirManager,
from distutils.command import build_ext
build_ext.USER_BASE = site.USER_BASE
- def _fixup_command(self, cmd):
- # When Python was build with --enable-shared, -L. is not good enough
- # to find the libpython<blah>.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 (sysconfig.get_config_var('Py_ENABLE_SHARED') and
- 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
copy_xxmodule_c(self.tmp_dir)
@@ -65,7 +46,7 @@ class BuildExtTestCase(TempdirManager,
dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
dist.package_dir = self.tmp_dir
cmd = build_ext(dist)
- self._fixup_command(cmd)
+ fixup_build_ext(cmd)
if os.name == "nt":
# On Windows, we must build a debug version iff running
# a debug build of Python
@@ -162,9 +143,9 @@ class BuildExtTestCase(TempdirManager,
# see if include_dirs and library_dirs
# were set
- self.assertTrue(lib in cmd.library_dirs)
- self.assertTrue(lib in cmd.rpath)
- self.assertTrue(incl in cmd.include_dirs)
+ self.assertIn(lib, cmd.library_dirs)
+ self.assertIn(lib, cmd.rpath)
+ self.assertIn(incl, cmd.include_dirs)
def test_optional_extension(self):
@@ -320,7 +301,7 @@ class BuildExtTestCase(TempdirManager,
dist = Distribution({'name': 'xx',
'ext_modules': [ext]})
cmd = build_ext(dist)
- self._fixup_command(cmd)
+ fixup_build_ext(cmd)
cmd.ensure_finalized()
self.assertEqual(len(cmd.get_outputs()), 1)
diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
index 2133fa7..e065aa3 100644
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -202,6 +202,7 @@ class InstallTestCase(support.TempdirManager,
support.copy_xxmodule_c(project_dir)
buildcmd = build_ext(dist)
+ support.fixup_build_ext(buildcmd)
buildcmd.ensure_finalized()
buildcmd.run()