- Issue #16754: Fix the incorrect shared library extension on linux. Introduce

two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
  SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
This commit is contained in:
doko@ubuntu.com 2013-03-21 13:39:52 -07:00
commit 6d3d0fe0b2
12 changed files with 87 additions and 101 deletions

View File

@ -368,9 +368,9 @@ In Python itself, the tags are accessible from functions in the :mod:`sysconfig`
module:: module::
>>> import sysconfig >>> import sysconfig
>>> sysconfig.get_config_var('SOABI') # find the version tag >>> sysconfig.get_config_var('SOABI') # find the version tag
'cpython-32mu' 'cpython-32mu'
>>> sysconfig.get_config_var('SO') # find the full filename extension >>> sysconfig.get_config_var('EXT_SUFFIX') # find the full filename extension
'.cpython-32mu.so' '.cpython-32mu.so'
.. seealso:: .. seealso::

View File

@ -666,10 +666,10 @@ class build_ext(Command):
from distutils.sysconfig import get_config_var from distutils.sysconfig import get_config_var
ext_path = ext_name.split('.') ext_path = ext_name.split('.')
# extensions in debug_mode are named 'module_d.pyd' under windows # extensions in debug_mode are named 'module_d.pyd' under windows
so_ext = get_config_var('SO') ext_suffix = get_config_var('EXT_SUFFIX')
if os.name == 'nt' and self.debug: if os.name == 'nt' and self.debug:
return os.path.join(*ext_path) + '_d' + so_ext return os.path.join(*ext_path) + '_d' + ext_suffix
return os.path.join(*ext_path) + so_ext return os.path.join(*ext_path) + ext_suffix
def get_export_symbols(self, ext): def get_export_symbols(self, ext):
"""Return the list of symbols that a shared extension has to """Return the list of symbols that a shared extension has to

View File

@ -184,9 +184,9 @@ def customize_compiler(compiler):
_osx_support.customize_compiler(_config_vars) _osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
newcc = None newcc = None
if 'CC' in os.environ: if 'CC' in os.environ:
@ -225,7 +225,7 @@ def customize_compiler(compiler):
linker_exe=cc, linker_exe=cc,
archiver=archiver) archiver=archiver)
compiler.shared_lib_extension = so_ext compiler.shared_lib_extension = shlib_suffix
def get_config_h_filename(): def get_config_h_filename():
@ -479,7 +479,7 @@ def _init_nt():
# XXX hmmm.. a normal install puts include files here # XXX hmmm.. a normal install puts include files here
g['INCLUDEPY'] = get_python_inc(plat_specific=0) g['INCLUDEPY'] = get_python_inc(plat_specific=0)
g['SO'] = '.pyd' g['EXT_SUFFIX'] = '.pyd'
g['EXE'] = ".exe" g['EXE'] = ".exe"
g['VERSION'] = get_python_version().replace(".", "") g['VERSION'] = get_python_version().replace(".", "")
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable)) g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))

View File

@ -318,8 +318,8 @@ class BuildExtTestCase(TempdirManager,
finally: finally:
os.chdir(old_wd) os.chdir(old_wd)
self.assertTrue(os.path.exists(so_file)) self.assertTrue(os.path.exists(so_file))
so_ext = sysconfig.get_config_var('SO') ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
self.assertTrue(so_file.endswith(so_ext)) self.assertTrue(so_file.endswith(ext_suffix))
so_dir = os.path.dirname(so_file) so_dir = os.path.dirname(so_file)
self.assertEqual(so_dir, other_tmp_dir) self.assertEqual(so_dir, other_tmp_dir)
@ -328,7 +328,7 @@ class BuildExtTestCase(TempdirManager,
cmd.run() cmd.run()
so_file = cmd.get_outputs()[0] so_file = cmd.get_outputs()[0]
self.assertTrue(os.path.exists(so_file)) self.assertTrue(os.path.exists(so_file))
self.assertTrue(so_file.endswith(so_ext)) self.assertTrue(so_file.endswith(ext_suffix))
so_dir = os.path.dirname(so_file) so_dir = os.path.dirname(so_file)
self.assertEqual(so_dir, cmd.build_lib) self.assertEqual(so_dir, cmd.build_lib)
@ -355,7 +355,7 @@ class BuildExtTestCase(TempdirManager,
self.assertEqual(lastdir, 'bar') self.assertEqual(lastdir, 'bar')
def test_ext_fullpath(self): def test_ext_fullpath(self):
ext = sysconfig.get_config_vars()['SO'] ext = sysconfig.get_config_var('EXT_SUFFIX')
# building lxml.etree inplace # building lxml.etree inplace
#etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c') #etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
#etree_ext = Extension('lxml.etree', [etree_c]) #etree_ext = Extension('lxml.etree', [etree_c])

View File

@ -23,7 +23,7 @@ from distutils.tests import support
def _make_ext_name(modname): def _make_ext_name(modname):
if os.name == 'nt' and sys.executable.endswith('_d.exe'): if os.name == 'nt' and sys.executable.endswith('_d.exe'):
modname += '_d' modname += '_d'
return modname + sysconfig.get_config_var('SO') return modname + sysconfig.get_config_var('EXT_SUFFIX')
class InstallTestCase(support.TempdirManager, class InstallTestCase(support.TempdirManager,

View File

@ -416,7 +416,7 @@ def _init_non_posix(vars):
vars['LIBDEST'] = get_path('stdlib') vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib') vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include') vars['INCLUDEPY'] = get_path('include')
vars['SO'] = '.pyd' vars['EXT_SUFFIX'] = '.pyd'
vars['EXE'] = '.exe' vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable)) vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))

View File

@ -125,7 +125,8 @@ INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION)
CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION) CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION)
# Symbols used for using shared libraries # Symbols used for using shared libraries
SO= @SO@ SHLIB_SUFFIX= @SHLIB_SUFFIX@
EXT_SUFFIX= @EXT_SUFFIX@
LDSHARED= @LDSHARED@ $(PY_LDFLAGS) LDSHARED= @LDSHARED@ $(PY_LDFLAGS)
BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS)
LDCXXSHARED= @LDCXXSHARED@ LDCXXSHARED= @LDCXXSHARED@
@ -652,6 +653,11 @@ Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
-DSOABI='"$(SOABI)"' \ -DSOABI='"$(SOABI)"' \
-o $@ $(srcdir)/Python/dynload_shlib.c -o $@ $(srcdir)/Python/dynload_shlib.c
Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
$(CC) -c $(PY_CORE_CFLAGS) \
-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
-o $@ $(srcdir)/Python/dynload_hpux.c
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
$(CC) -c $(PY_CORE_CFLAGS) \ $(CC) -c $(PY_CORE_CFLAGS) \
-DABIFLAGS='"$(ABIFLAGS)"' \ -DABIFLAGS='"$(ABIFLAGS)"' \
@ -1188,7 +1194,7 @@ libainstall: all python-config
done done
@if test -d $(LIBRARY); then :; else \ @if test -d $(LIBRARY); then :; else \
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
if test "$(SO)" = .dll; then \ if test "$(SHLIB_SUFFIX)" = .dll; then \
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \ $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
else \ else \
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \ $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \

View File

@ -1121,6 +1121,10 @@ Tests
Build Build
----- -----
- Issue #16754: Fix the incorrect shared library extension on linux. Introduce
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
- Issue #5033: Fix building of the sqlite3 extension module when the - Issue #5033: Fix building of the sqlite3 extension module when the
SQLite library version has "beta" in it. Patch by Andreas Pelme. SQLite library version has "beta" in it. Patch by Andreas Pelme.

View File

@ -57,7 +57,7 @@ for opt in opt_flags:
print(' '.join(libs)) print(' '.join(libs))
elif opt == '--extension-suffix': elif opt == '--extension-suffix':
print(sysconfig.get_config_var('SO')) print(sysconfig.get_config_var('EXT_SUFFIX'))
elif opt == '--abiflags': elif opt == '--abiflags':
print(sys.abiflags) print(sys.abiflags)

69
configure vendored
View File

@ -627,6 +627,7 @@ SRCDIRS
THREADHEADERS THREADHEADERS
LIBPL LIBPL
PY_ENABLE_SHARED PY_ENABLE_SHARED
EXT_SUFFIX
SOABI SOABI
LIBC LIBC
LIBM LIBM
@ -654,7 +655,7 @@ CCSHARED
BLDSHARED BLDSHARED
LDCXXSHARED LDCXXSHARED
LDSHARED LDSHARED
SO SHLIB_SUFFIX
LIBTOOL_CRUFT LIBTOOL_CRUFT
OTHER_LIBTOOL_OPT OTHER_LIBTOOL_OPT
UNIVERSAL_ARCH_FLAGS UNIVERSAL_ARCH_FLAGS
@ -8396,6 +8397,25 @@ esac
# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
# -- usually .so, .sl on HP-UX, .dll on Cygwin
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the extension of shared libraries" >&5
$as_echo_n "checking the extension of shared libraries... " >&6; }
if test -z "$SHLIB_SUFFIX"; then
case $ac_sys_system in
hp*|HP*)
case `uname -m` in
ia64) SHLIB_SUFFIX=.so;;
*) SHLIB_SUFFIX=.sl;;
esac
;;
CYGWIN*) SHLIB_SUFFIX=.dll;;
*) SHLIB_SUFFIX=.so;;
esac
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLIB_SUFFIX" >&5
$as_echo "$SHLIB_SUFFIX" >&6; }
# LDSHARED is the ld *command* used to create shared library # LDSHARED is the ld *command* used to create shared library
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
# (Shared libraries in this instance are shared modules to be loaded into # (Shared libraries in this instance are shared modules to be loaded into
@ -13689,6 +13709,14 @@ SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
$as_echo "$SOABI" >&6; } $as_echo "$SOABI" >&6; }
case $ac_sys_system in
Linux*|GNU*)
EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
*)
EXT_SUFFIX=${SHLIB_SUFFIX};;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5
$as_echo_n "checking LDVERSION... " >&6; } $as_echo_n "checking LDVERSION... " >&6; }
LDVERSION='$(VERSION)$(ABIFLAGS)' LDVERSION='$(VERSION)$(ABIFLAGS)'
@ -13699,45 +13727,6 @@ $as_echo "$LDVERSION" >&6; }
LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}" LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}"
# SO is the extension of shared libraries `(including the dot!)
# -- usually .so, .sl on HP-UX, .dll on Cygwin
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5
$as_echo_n "checking SO... " >&6; }
if test -z "$SO"
then
case $ac_sys_system in
hp*|HP*)
case `uname -m` in
ia64) SO=.so;;
*) SO=.sl;;
esac
;;
CYGWIN*) SO=.dll;;
Linux*|GNU*)
SO=.${SOABI}.so;;
*) SO=.so;;
esac
else
# this might also be a termcap variable, see #610332
echo
echo '====================================================================='
echo '+ +'
echo '+ WARNING: You have set SO in your environment. +'
echo '+ Do you really mean to change the extension for shared libraries? +'
echo '+ Continuing in 10 seconds to let you to ponder. +'
echo '+ +'
echo '====================================================================='
sleep 10
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SO" >&5
$as_echo "$SO" >&6; }
cat >>confdefs.h <<_ACEOF
#define SHLIB_EXT "$SO"
_ACEOF
# Check whether right shifting a negative integer extends the sign bit # Check whether right shifting a negative integer extends the sign bit
# or fills with zeros (like the Cray J90, according to Tim Peters). # or fills with zeros (like the Cray J90, according to Tim Peters).
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5

View File

@ -1898,13 +1898,30 @@ case $ac_sys_system/$ac_sys_release in
esac esac
# Set info about shared libraries. # Set info about shared libraries.
AC_SUBST(SO) AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(LDSHARED) AC_SUBST(LDSHARED)
AC_SUBST(LDCXXSHARED) AC_SUBST(LDCXXSHARED)
AC_SUBST(BLDSHARED) AC_SUBST(BLDSHARED)
AC_SUBST(CCSHARED) AC_SUBST(CCSHARED)
AC_SUBST(LINKFORSHARED) AC_SUBST(LINKFORSHARED)
# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
# -- usually .so, .sl on HP-UX, .dll on Cygwin
AC_MSG_CHECKING(the extension of shared libraries)
if test -z "$SHLIB_SUFFIX"; then
case $ac_sys_system in
hp*|HP*)
case `uname -m` in
ia64) SHLIB_SUFFIX=.so;;
*) SHLIB_SUFFIX=.sl;;
esac
;;
CYGWIN*) SHLIB_SUFFIX=.dll;;
*) SHLIB_SUFFIX=.so;;
esac
fi
AC_MSG_RESULT($SHLIB_SUFFIX)
# LDSHARED is the ld *command* used to create shared library # LDSHARED is the ld *command* used to create shared library
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
# (Shared libraries in this instance are shared modules to be loaded into # (Shared libraries in this instance are shared modules to be loaded into
@ -3927,6 +3944,14 @@ AC_MSG_CHECKING(SOABI)
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS} SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
AC_MSG_RESULT($SOABI) AC_MSG_RESULT($SOABI)
AC_SUBST(EXT_SUFFIX)
case $ac_sys_system in
Linux*|GNU*)
EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
*)
EXT_SUFFIX=${SHLIB_SUFFIX};;
esac
AC_MSG_CHECKING(LDVERSION) AC_MSG_CHECKING(LDVERSION)
LDVERSION='$(VERSION)$(ABIFLAGS)' LDVERSION='$(VERSION)$(ABIFLAGS)'
AC_MSG_RESULT($LDVERSION) AC_MSG_RESULT($LDVERSION)
@ -3936,39 +3961,6 @@ AC_SUBST(PY_ENABLE_SHARED)
LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}" LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}"
AC_SUBST(LIBPL) AC_SUBST(LIBPL)
# SO is the extension of shared libraries `(including the dot!)
# -- usually .so, .sl on HP-UX, .dll on Cygwin
AC_MSG_CHECKING(SO)
if test -z "$SO"
then
case $ac_sys_system in
hp*|HP*)
case `uname -m` in
ia64) SO=.so;;
*) SO=.sl;;
esac
;;
CYGWIN*) SO=.dll;;
Linux*|GNU*)
SO=.${SOABI}.so;;
*) SO=.so;;
esac
else
# this might also be a termcap variable, see #610332
echo
echo '====================================================================='
echo '+ +'
echo '+ WARNING: You have set SO in your environment. +'
echo '+ Do you really mean to change the extension for shared libraries? +'
echo '+ Continuing in 10 seconds to let you to ponder. +'
echo '+ +'
echo '====================================================================='
sleep 10
fi
AC_MSG_RESULT($SO)
AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
# Check whether right shifting a negative integer extends the sign bit # Check whether right shifting a negative integer extends the sign bit
# or fills with zeros (like the Cray J90, according to Tim Peters). # or fills with zeros (like the Cray J90, according to Tim Peters).
AC_MSG_CHECKING(whether right shift extends the sign bit) AC_MSG_CHECKING(whether right shift extends the sign bit)

View File

@ -169,13 +169,7 @@ class PyBuildExt(build_ext):
def build_extensions(self): def build_extensions(self):
# Detect which modules should be compiled # Detect which modules should be compiled
old_so = self.compiler.shared_lib_extension missing = self.detect_modules()
# Workaround PEP 3149 stuff
self.compiler.shared_lib_extension = os.environ.get("SO", ".so")
try:
missing = self.detect_modules()
finally:
self.compiler.shared_lib_extension = old_so
# Remove modules that are present on the disabled list # Remove modules that are present on the disabled list
extensions = [ext for ext in self.extensions extensions = [ext for ext in self.extensions
@ -2066,7 +2060,8 @@ class PyBuildInstallLib(install_lib):
# mode 644 unless they are a shared library in which case they will get # mode 644 unless they are a shared library in which case they will get
# mode 755. All installed directories will get mode 755. # mode 755. All installed directories will get mode 755.
so_ext = sysconfig.get_config_var("SO") # this is works for EXT_SUFFIX too, which ends with SHLIB_SUFFIX
shlib_suffix = sysconfig.get_config_var("SHLIB_SUFFIX")
def install(self): def install(self):
outfiles = install_lib.install(self) outfiles = install_lib.install(self)
@ -2081,7 +2076,7 @@ class PyBuildInstallLib(install_lib):
for filename in files: for filename in files:
if os.path.islink(filename): continue if os.path.islink(filename): continue
mode = defaultMode mode = defaultMode
if filename.endswith(self.so_ext): mode = sharedLibMode if filename.endswith(self.shlib_suffix): mode = sharedLibMode
log.info("changing mode of %s to %o", filename, mode) log.info("changing mode of %s to %o", filename, mode)
if not self.dry_run: os.chmod(filename, mode) if not self.dry_run: os.chmod(filename, mode)