summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/support.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-08-21 15:02:07 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-08-21 15:02:07 (GMT)
commit6e3ad8736ec4efcc471b3db38279ab56b7f12bef (patch)
tree54e12603ecf8a17467f6ddf4eca4f6ad9016ac6a /Lib/distutils/tests/support.py
parent5fa8e7a559be10233c035ac2f29a9a87bf2c4eb7 (diff)
downloadcpython-6e3ad8736ec4efcc471b3db38279ab56b7f12bef.zip
cpython-6e3ad8736ec4efcc471b3db38279ab56b7f12bef.tar.gz
cpython-6e3ad8736ec4efcc471b3db38279ab56b7f12bef.tar.bz2
Factor out the build_ext fixup for shared Python builds.
I need this to fix the failing test_install.
Diffstat (limited to 'Lib/distutils/tests/support.py')
-rw-r--r--Lib/distutils/tests/support.py27
1 files changed, 27 insertions, 0 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)