diff options
author | Barry Warsaw <barry@python.org> | 2010-10-16 01:04:07 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2010-10-16 01:04:07 (GMT) |
commit | 8cf4eae522592549a92b7b599838f63ba56120cd (patch) | |
tree | 76c8a9608c4efa297a67938429970361e3655d1f /Lib/distutils | |
parent | d8d835bd1daa2d097c0d9a9ad1826d2bc111e19e (diff) | |
download | cpython-8cf4eae522592549a92b7b599838f63ba56120cd.zip cpython-8cf4eae522592549a92b7b599838f63ba56120cd.tar.gz cpython-8cf4eae522592549a92b7b599838f63ba56120cd.tar.bz2 |
First (uncontroversial) part of issue 9807.
* Expose the build flags to Python as sys.abiflags
* Shared library libpythonX.Y<abiflags>.so
* python-config --abiflags
* Make two distutils tests that failed with --enable-shared (even before this
patch) succeed.
* Fix a few small style issues.
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/command/build_ext.py | 6 | ||||
-rw-r--r-- | Lib/distutils/tests/test_build_ext.py | 26 |
2 files changed, 24 insertions, 8 deletions
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index 4e66464..cc0d414 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -754,9 +754,9 @@ class build_ext(Command): else: from distutils import sysconfig if sysconfig.get_config_var('Py_ENABLE_SHARED'): - template = "python%d.%d" - pythonlib = (template % - (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) + pythonlib = 'python{}.{}{}'.format( + sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff, + sys.abiflags) return ext.libraries + [pythonlib] else: return ext.libraries diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py index 52479d7..4351c0f 100644 --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -1,17 +1,16 @@ import sys import os -import tempfile import shutil from io import StringIO -from distutils.core import Extension, Distribution +from distutils.core import Distribution from distutils.command.build_ext import build_ext from distutils import sysconfig from distutils.tests.support import TempdirManager from distutils.tests.support import LoggingSilencer from distutils.extension import Extension -from distutils.errors import (UnknownFileError, DistutilsSetupError, - CompileError) +from distutils.errors import ( + CompileError, DistutilsSetupError, UnknownFileError) import unittest from test import support @@ -42,6 +41,20 @@ 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 not sys.platform.startswith('win'): + library_dir = sysconfig.get_config_var('srcdir') + cmd.library_dirs = [('.' if library_dir is None else library_dir)] + def test_build_ext(self): global ALREADY_TESTED xx_c = os.path.join(self.tmp_dir, 'xxmodule.c') @@ -49,6 +62,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) if os.name == "nt": # On Windows, we must build a debug version iff running # a debug build of Python @@ -235,7 +249,8 @@ class BuildExtTestCase(TempdirManager, cmd.finalize_options() #'extensions' option must be a list of Extension instances - self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, 'foo') + self.assertRaises(DistutilsSetupError, + cmd.check_extensions_list, 'foo') # each element of 'ext_modules' option must be an # Extension instance or 2-tuple @@ -302,6 +317,7 @@ class BuildExtTestCase(TempdirManager, 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) |