From 0d4fd3493eb95a49ac0dee5c8607b1426432ab83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarek=20Ziad=C3=A9?= Date: Thu, 5 Feb 2009 22:52:52 +0000 Subject: Fixed #5132: enable extensions to link on Solaris --- Lib/distutils/command/build_ext.py | 8 +++++--- Lib/distutils/tests/test_build_ext.py | 21 +++++++++++++++++++++ Misc/NEWS | 3 +++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index fbf2a0b..2ed3ef6 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -231,10 +231,12 @@ class build_ext (Command): # building python standard extensions self.library_dirs.append('.') - # for extensions under Linux with a shared Python library, + # for extensions under Linux or Solaris with a shared Python library, # Python's library directory must be appended to library_dirs - if (sys.platform.startswith('linux') or sys.platform.startswith('gnu')) \ - and sysconfig.get_config_var('Py_ENABLE_SHARED'): + sysconfig.get_config_var('Py_ENABLE_SHARED') + if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') + or sys.platform.startswith('sunos')) + and sysconfig.get_config_var('Py_ENABLE_SHARED')): if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py index b268820..780660d 100644 --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -67,6 +67,27 @@ class BuildExtTestCase(unittest.TestCase): # XXX on Windows the test leaves a directory with xx module in TEMP shutil.rmtree(self.tmp_dir, os.name == 'nt' or sys.platform == 'cygwin') + def test_solaris_enable_shared(self): + dist = Distribution({'name': 'xx'}) + cmd = build_ext(dist) + old = sys.platform + + sys.platform = 'sunos' # fooling finalize_options + from distutils.sysconfig import _config_vars + old_var = _config_vars.get('Py_ENABLE_SHARED') + _config_vars['Py_ENABLE_SHARED'] = 1 + try: + cmd.ensure_finalized() + finally: + sys.platform = old + if old_var is None: + del _config_vars['Py_ENABLE_SHARED'] + else: + _config_vars['Py_ENABLE_SHARED'] = old_var + + # make sur we get some lobrary dirs under solaris + self.assert_(len(cmd.library_dirs) > 0) + def test_suite(): src = _get_source_filename() if not os.path.exists(src): diff --git a/Misc/NEWS b/Misc/NEWS index 4954c8b..bf4c916 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -149,6 +149,9 @@ Core and Builtins Library ------- +- Issue #5132: Fixed trouble building extensions under Solaris with + --enabled-shared activated. Initial patch by Dave Peterson. + - Issue #1581476: Always use the Tcl global namespace when calling into Tcl. - Issue #2047: shutil.move() could believe that its destination path was -- cgit v0.12