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

Skip to content

Commit d5537d0

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.
1 parent 03b0116 commit d5537d0

13 files changed

Lines changed: 88 additions & 99 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
@@ -667,10 +667,10 @@ def get_ext_filename(self, ext_name):
667667
if os.name == "os2":
668668
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
669669
# extensions in debug_mode are named 'module_d.pyd' under windows
670-
so_ext = get_config_var('SO')
670+
ext_suffix = get_config_var('EXT_SUFFIX')
671671
if os.name == 'nt' and self.debug:
672-
return os.path.join(*ext_path) + '_d' + so_ext
673-
return os.path.join(*ext_path) + so_ext
672+
return os.path.join(*ext_path) + '_d' + ext_suffix
673+
return os.path.join(*ext_path) + ext_suffix
674674

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

Lib/distutils/sysconfig.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ def customize_compiler(compiler):
170170
_osx_support.customize_compiler(_config_vars)
171171
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
172172

173-
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
173+
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
174174
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
175-
'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
175+
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
176176

177177
newcc = None
178178
if 'CC' in os.environ:
@@ -211,7 +211,7 @@ def customize_compiler(compiler):
211211
linker_exe=cc,
212212
archiver=archiver)
213213

214-
compiler.shared_lib_extension = so_ext
214+
compiler.shared_lib_extension = shlib_suffix
215215

216216

217217
def get_config_h_filename():
@@ -466,6 +466,7 @@ def _init_nt():
466466
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
467467

468468
g['SO'] = '.pyd'
469+
g['EXT_SUFFIX'] = '.pyd'
469470
g['EXE'] = ".exe"
470471
g['VERSION'] = get_python_version().replace(".", "")
471472
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
@@ -485,6 +486,7 @@ def _init_os2():
485486
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
486487

487488
g['SO'] = '.pyd'
489+
g['EXT_SUFFIX'] = '.pyd'
488490
g['EXE'] = ".exe"
489491

490492
global _config_vars

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def _init_non_posix(vars):
360360
vars['BINLIBDEST'] = get_path('platstdlib')
361361
vars['INCLUDEPY'] = get_path('include')
362362
vars['SO'] = '.pyd'
363+
vars['EXT_SUFFIX'] = '.pyd'
363364
vars['EXE'] = '.exe'
364365
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
365366
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))

Makefile.pre.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ 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@
130+
SO= $(SHLIB_SUFFIX)
129131
LDSHARED= @LDSHARED@ $(PY_LDFLAGS)
130132
BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS)
131133
LDCXXSHARED= @LDCXXSHARED@
@@ -598,6 +600,11 @@ Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
598600
-DSOABI='"$(SOABI)"' \
599601
-o $@ $(srcdir)/Python/dynload_shlib.c
600602

603+
Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
604+
$(CC) -c $(PY_CORE_CFLAGS) \
605+
-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
606+
-o $@ $(srcdir)/Python/dynload_hpux.c
607+
601608
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
602609
$(CC) -c $(PY_CORE_CFLAGS) \
603610
-DABIFLAGS='"$(ABIFLAGS)"' \
@@ -1098,7 +1105,7 @@ libainstall: all python-config
10981105
done
10991106
@if test -d $(LIBRARY); then :; else \
11001107
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1101-
if test "$(SO)" = .dll; then \
1108+
if test "$(SHLIB_SUFFIX)" = .dll; then \
11021109
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
11031110
else \
11041111
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,10 @@ Tests
10731073
Build
10741074
-----
10751075

1076+
- Issue #16754: Fix the incorrect shared library extension on linux. Introduce
1077+
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
1078+
SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
1079+
10761080
- Issue #5033: Fix building of the sqlite3 extension module when the
10771081
SQLite library version has "beta" in it. Patch by Andreas Pelme.
10781082

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: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ ac_includes_default="\
626626
ac_subst_vars='LTLIBOBJS
627627
SRCDIRS
628628
THREADHEADERS
629+
EXT_SUFFIX
629630
SOABI
630631
LIBC
631632
LIBM
@@ -653,7 +654,7 @@ CCSHARED
653654
BLDSHARED
654655
LDCXXSHARED
655656
LDSHARED
656-
SO
657+
SHLIB_SUFFIX
657658
LIBTOOL_CRUFT
658659
OTHER_LIBTOOL_OPT
659660
UNIVERSAL_ARCH_FLAGS
@@ -7701,10 +7702,24 @@ esac
77017702

77027703

77037704

7704-
7705-
cat >>confdefs.h <<_ACEOF
7706-
#define SHLIB_EXT "$SO"
7707-
_ACEOF
7705+
# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
7706+
# -- usually .so, .sl on HP-UX, .dll on Cygwin
7707+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the extension of shared libraries" >&5
7708+
$as_echo_n "checking the extension of shared libraries... " >&6; }
7709+
if test -z "$SHLIB_SUFFIX"; then
7710+
case $ac_sys_system in
7711+
hp*|HP*)
7712+
case `uname -m` in
7713+
ia64) SHLIB_SUFFIX=.so;;
7714+
*) SHLIB_SUFFIX=.sl;;
7715+
esac
7716+
;;
7717+
CYGWIN*) SHLIB_SUFFIX=.dll;;
7718+
*) SHLIB_SUFFIX=.so;;
7719+
esac
7720+
fi
7721+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLIB_SUFFIX" >&5
7722+
$as_echo "$SHLIB_SUFFIX" >&6; }
77087723

77097724
# LDSHARED is the ld *command* used to create shared library
77107725
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
@@ -12843,45 +12858,20 @@ SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
1284312858
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
1284412859
$as_echo "$SOABI" >&6; }
1284512860

12861+
12862+
case $ac_sys_system in
12863+
Linux*|GNU*)
12864+
EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
12865+
*)
12866+
EXT_SUFFIX=${SHLIB_SUFFIX};;
12867+
esac
12868+
1284612869
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5
1284712870
$as_echo_n "checking LDVERSION... " >&6; }
1284812871
LDVERSION='$(VERSION)$(ABIFLAGS)'
1284912872
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDVERSION" >&5
1285012873
$as_echo "$LDVERSION" >&6; }
1285112874

12852-
# SO is the extension of shared libraries `(including the dot!)
12853-
# -- usually .so, .sl on HP-UX, .dll on Cygwin
12854-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5
12855-
$as_echo_n "checking SO... " >&6; }
12856-
if test -z "$SO"
12857-
then
12858-
case $ac_sys_system in
12859-
hp*|HP*)
12860-
case `uname -m` in
12861-
ia64) SO=.so;;
12862-
*) SO=.sl;;
12863-
esac
12864-
;;
12865-
CYGWIN*) SO=.dll;;
12866-
Linux*|GNU*)
12867-
SO=.${SOABI}.so;;
12868-
*) SO=.so;;
12869-
esac
12870-
else
12871-
# this might also be a termcap variable, see #610332
12872-
echo
12873-
echo '====================================================================='
12874-
echo '+ +'
12875-
echo '+ WARNING: You have set SO in your environment. +'
12876-
echo '+ Do you really mean to change the extension for shared libraries? +'
12877-
echo '+ Continuing in 10 seconds to let you to ponder. +'
12878-
echo '+ +'
12879-
echo '====================================================================='
12880-
sleep 10
12881-
fi
12882-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SO" >&5
12883-
$as_echo "$SO" >&6; }
12884-
1288512875
# Check whether right shifting a negative integer extends the sign bit
1288612876
# or fills with zeros (like the Cray J90, according to Tim Peters).
1288712877
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5

0 commit comments

Comments
 (0)