Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d3d0fe

Browse files
committed
- 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.
2 parents d06b35c + 1621d77 commit 6d3d0fe

12 files changed

Lines changed: 87 additions & 101 deletions

File tree

Doc/whatsnew/3.2.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,9 @@ In Python itself, the tags are accessible from functions in the :mod:`sysconfig`
368368
module::
369369

370370
>>> import sysconfig
371-
>>> sysconfig.get_config_var('SOABI') # find the version tag
371+
>>> sysconfig.get_config_var('SOABI') # find the version tag
372372
'cpython-32mu'
373-
>>> sysconfig.get_config_var('SO') # find the full filename extension
373+
>>> sysconfig.get_config_var('EXT_SUFFIX') # find the full filename extension
374374
'.cpython-32mu.so'
375375

376376
.. seealso::

Lib/distutils/command/build_ext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,10 @@ def get_ext_filename(self, ext_name):
666666
from distutils.sysconfig import get_config_var
667667
ext_path = ext_name.split('.')
668668
# extensions in debug_mode are named 'module_d.pyd' under windows
669-
so_ext = get_config_var('SO')
669+
ext_suffix = get_config_var('EXT_SUFFIX')
670670
if os.name == 'nt' and self.debug:
671-
return os.path.join(*ext_path) + '_d' + so_ext
672-
return os.path.join(*ext_path) + so_ext
671+
return os.path.join(*ext_path) + '_d' + ext_suffix
672+
return os.path.join(*ext_path) + ext_suffix
673673

674674
def get_export_symbols(self, ext):
675675
"""Return the list of symbols that a shared extension has to

Lib/distutils/sysconfig.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def customize_compiler(compiler):
184184
_osx_support.customize_compiler(_config_vars)
185185
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
186186

187-
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
187+
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
188188
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
189-
'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
189+
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
190190

191191
newcc = None
192192
if 'CC' in os.environ:
@@ -225,7 +225,7 @@ def customize_compiler(compiler):
225225
linker_exe=cc,
226226
archiver=archiver)
227227

228-
compiler.shared_lib_extension = so_ext
228+
compiler.shared_lib_extension = shlib_suffix
229229

230230

231231
def get_config_h_filename():
@@ -479,7 +479,7 @@ def _init_nt():
479479
# XXX hmmm.. a normal install puts include files here
480480
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
481481

482-
g['SO'] = '.pyd'
482+
g['EXT_SUFFIX'] = '.pyd'
483483
g['EXE'] = ".exe"
484484
g['VERSION'] = get_python_version().replace(".", "")
485485
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))

Lib/distutils/tests/test_build_ext.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ def test_get_outputs(self):
318318
finally:
319319
os.chdir(old_wd)
320320
self.assertTrue(os.path.exists(so_file))
321-
so_ext = sysconfig.get_config_var('SO')
322-
self.assertTrue(so_file.endswith(so_ext))
321+
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
322+
self.assertTrue(so_file.endswith(ext_suffix))
323323
so_dir = os.path.dirname(so_file)
324324
self.assertEqual(so_dir, other_tmp_dir)
325325

@@ -328,7 +328,7 @@ def test_get_outputs(self):
328328
cmd.run()
329329
so_file = cmd.get_outputs()[0]
330330
self.assertTrue(os.path.exists(so_file))
331-
self.assertTrue(so_file.endswith(so_ext))
331+
self.assertTrue(so_file.endswith(ext_suffix))
332332
so_dir = os.path.dirname(so_file)
333333
self.assertEqual(so_dir, cmd.build_lib)
334334

@@ -355,7 +355,7 @@ def test_get_outputs(self):
355355
self.assertEqual(lastdir, 'bar')
356356

357357
def test_ext_fullpath(self):
358-
ext = sysconfig.get_config_vars()['SO']
358+
ext = sysconfig.get_config_var('EXT_SUFFIX')
359359
# building lxml.etree inplace
360360
#etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
361361
#etree_ext = Extension('lxml.etree', [etree_c])

Lib/distutils/tests/test_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
def _make_ext_name(modname):
2424
if os.name == 'nt' and sys.executable.endswith('_d.exe'):
2525
modname += '_d'
26-
return modname + sysconfig.get_config_var('SO')
26+
return modname + sysconfig.get_config_var('EXT_SUFFIX')
2727

2828

2929
class InstallTestCase(support.TempdirManager,

Lib/sysconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def _init_non_posix(vars):
416416
vars['LIBDEST'] = get_path('stdlib')
417417
vars['BINLIBDEST'] = get_path('platstdlib')
418418
vars['INCLUDEPY'] = get_path('include')
419-
vars['SO'] = '.pyd'
419+
vars['EXT_SUFFIX'] = '.pyd'
420420
vars['EXE'] = '.exe'
421421
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
422422
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))

Makefile.pre.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION)
125125
CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION)
126126

127127
# Symbols used for using shared libraries
128-
SO= @SO@
128+
SHLIB_SUFFIX= @SHLIB_SUFFIX@
129+
EXT_SUFFIX= @EXT_SUFFIX@
129130
LDSHARED= @LDSHARED@ $(PY_LDFLAGS)
130131
BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS)
131132
LDCXXSHARED= @LDCXXSHARED@
@@ -652,6 +653,11 @@ Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
652653
-DSOABI='"$(SOABI)"' \
653654
-o $@ $(srcdir)/Python/dynload_shlib.c
654655

656+
Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
657+
$(CC) -c $(PY_CORE_CFLAGS) \
658+
-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
659+
-o $@ $(srcdir)/Python/dynload_hpux.c
660+
655661
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
656662
$(CC) -c $(PY_CORE_CFLAGS) \
657663
-DABIFLAGS='"$(ABIFLAGS)"' \
@@ -1188,7 +1194,7 @@ libainstall: all python-config
11881194
done
11891195
@if test -d $(LIBRARY); then :; else \
11901196
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1191-
if test "$(SO)" = .dll; then \
1197+
if test "$(SHLIB_SUFFIX)" = .dll; then \
11921198
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
11931199
else \
11941200
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,10 @@ Tests
11211121
Build
11221122
-----
11231123

1124+
- Issue #16754: Fix the incorrect shared library extension on linux. Introduce
1125+
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
1126+
SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
1127+
11241128
- Issue #5033: Fix building of the sqlite3 extension module when the
11251129
SQLite library version has "beta" in it. Patch by Andreas Pelme.
11261130

Misc/python-config.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ for opt in opt_flags:
5757
print(' '.join(libs))
5858

5959
elif opt == '--extension-suffix':
60-
print(sysconfig.get_config_var('SO'))
60+
print(sysconfig.get_config_var('EXT_SUFFIX'))
6161

6262
elif opt == '--abiflags':
6363
print(sys.abiflags)

configure

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ SRCDIRS
627627
THREADHEADERS
628628
LIBPL
629629
PY_ENABLE_SHARED
630+
EXT_SUFFIX
630631
SOABI
631632
LIBC
632633
LIBM
@@ -654,7 +655,7 @@ CCSHARED
654655
BLDSHARED
655656
LDCXXSHARED
656657
LDSHARED
657-
SO
658+
SHLIB_SUFFIX
658659
LIBTOOL_CRUFT
659660
OTHER_LIBTOOL_OPT
660661
UNIVERSAL_ARCH_FLAGS
@@ -8396,6 +8397,25 @@ esac
83968397

83978398

83988399

8400+
# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
8401+
# -- usually .so, .sl on HP-UX, .dll on Cygwin
8402+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the extension of shared libraries" >&5
8403+
$as_echo_n "checking the extension of shared libraries... " >&6; }
8404+
if test -z "$SHLIB_SUFFIX"; then
8405+
case $ac_sys_system in
8406+
hp*|HP*)
8407+
case `uname -m` in
8408+
ia64) SHLIB_SUFFIX=.so;;
8409+
*) SHLIB_SUFFIX=.sl;;
8410+
esac
8411+
;;
8412+
CYGWIN*) SHLIB_SUFFIX=.dll;;
8413+
*) SHLIB_SUFFIX=.so;;
8414+
esac
8415+
fi
8416+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLIB_SUFFIX" >&5
8417+
$as_echo "$SHLIB_SUFFIX" >&6; }
8418+
83998419
# LDSHARED is the ld *command* used to create shared library
84008420
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
84018421
# (Shared libraries in this instance are shared modules to be loaded into
@@ -13689,6 +13709,14 @@ SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
1368913709
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
1369013710
$as_echo "$SOABI" >&6; }
1369113711

13712+
13713+
case $ac_sys_system in
13714+
Linux*|GNU*)
13715+
EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
13716+
*)
13717+
EXT_SUFFIX=${SHLIB_SUFFIX};;
13718+
esac
13719+
1369213720
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5
1369313721
$as_echo_n "checking LDVERSION... " >&6; }
1369413722
LDVERSION='$(VERSION)$(ABIFLAGS)'
@@ -13699,45 +13727,6 @@ $as_echo "$LDVERSION" >&6; }
1369913727
LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}"
1370013728

1370113729

13702-
# SO is the extension of shared libraries `(including the dot!)
13703-
# -- usually .so, .sl on HP-UX, .dll on Cygwin
13704-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5
13705-
$as_echo_n "checking SO... " >&6; }
13706-
if test -z "$SO"
13707-
then
13708-
case $ac_sys_system in
13709-
hp*|HP*)
13710-
case `uname -m` in
13711-
ia64) SO=.so;;
13712-
*) SO=.sl;;
13713-
esac
13714-
;;
13715-
CYGWIN*) SO=.dll;;
13716-
Linux*|GNU*)
13717-
SO=.${SOABI}.so;;
13718-
*) SO=.so;;
13719-
esac
13720-
else
13721-
# this might also be a termcap variable, see #610332
13722-
echo
13723-
echo '====================================================================='
13724-
echo '+ +'
13725-
echo '+ WARNING: You have set SO in your environment. +'
13726-
echo '+ Do you really mean to change the extension for shared libraries? +'
13727-
echo '+ Continuing in 10 seconds to let you to ponder. +'
13728-
echo '+ +'
13729-
echo '====================================================================='
13730-
sleep 10
13731-
fi
13732-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SO" >&5
13733-
$as_echo "$SO" >&6; }
13734-
13735-
13736-
cat >>confdefs.h <<_ACEOF
13737-
#define SHLIB_EXT "$SO"
13738-
_ACEOF
13739-
13740-
1374113730
# Check whether right shifting a negative integer extends the sign bit
1374213731
# or fills with zeros (like the Cray J90, according to Tim Peters).
1374313732
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5

0 commit comments

Comments
 (0)