X Tutup
Skip to content

Commit 1621d77

Browse files
committed
- Issue python#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 bd2d30c + d5537d0 commit 1621d77

File tree

12 files changed

+89
-99
lines changed

12 files changed

+89
-99
lines changed

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
@@ -677,10 +677,10 @@ def get_ext_filename(self, ext_name):
677677
if os.name == "os2":
678678
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
679679
# extensions in debug_mode are named 'module_d.pyd' under windows
680-
so_ext = get_config_var('SO')
680+
ext_suffix = get_config_var('EXT_SUFFIX')
681681
if os.name == 'nt' and self.debug:
682-
return os.path.join(*ext_path) + '_d' + so_ext
683-
return os.path.join(*ext_path) + so_ext
682+
return os.path.join(*ext_path) + '_d' + ext_suffix
683+
return os.path.join(*ext_path) + ext_suffix
684684

685685
def get_export_symbols(self, ext):
686686
"""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
@@ -191,9 +191,9 @@ def customize_compiler(compiler):
191191
_osx_support.customize_compiler(_config_vars)
192192
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
193193

194-
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
194+
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
195195
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
196-
'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
196+
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
197197

198198
newcc = None
199199
if 'CC' in os.environ:
@@ -232,7 +232,7 @@ def customize_compiler(compiler):
232232
linker_exe=cc,
233233
archiver=archiver)
234234

235-
compiler.shared_lib_extension = so_ext
235+
compiler.shared_lib_extension = shlib_suffix
236236

237237

238238
def get_config_h_filename():
@@ -487,6 +487,7 @@ def _init_nt():
487487
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
488488

489489
g['SO'] = '.pyd'
490+
g['EXT_SUFFIX'] = '.pyd'
490491
g['EXE'] = ".exe"
491492
g['VERSION'] = get_python_version().replace(".", "")
492493
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
@@ -506,6 +507,7 @@ def _init_os2():
506507
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
507508

508509
g['SO'] = '.pyd'
510+
g['EXT_SUFFIX'] = '.pyd'
509511
g['EXE'] = ".exe"
510512

511513
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
@@ -437,6 +437,7 @@ def _init_non_posix(vars):
437437
vars['BINLIBDEST'] = get_path('platstdlib')
438438
vars['INCLUDEPY'] = get_path('include')
439439
vars['SO'] = '.pyd'
440+
vars['EXT_SUFFIX'] = '.pyd'
440441
vars['EXE'] = '.exe'
441442
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
442443
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@
@@ -652,6 +654,11 @@ Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
652654
-DSOABI='"$(SOABI)"' \
653655
-o $@ $(srcdir)/Python/dynload_shlib.c
654656

657+
Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
658+
$(CC) -c $(PY_CORE_CFLAGS) \
659+
-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
660+
-o $@ $(srcdir)/Python/dynload_hpux.c
661+
655662
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
656663
$(CC) -c $(PY_CORE_CFLAGS) \
657664
-DABIFLAGS='"$(ABIFLAGS)"' \
@@ -1186,7 +1193,7 @@ libainstall: all python-config
11861193
done
11871194
@if test -d $(LIBRARY); then :; else \
11881195
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1189-
if test "$(SO)" = .dll; then \
1196+
if test "$(SHLIB_SUFFIX)" = .dll; then \
11901197
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
11911198
else \
11921199
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,10 @@ Tests
794794
Build
795795
-----
796796

797+
- Issue #16754: Fix the incorrect shared library extension on linux. Introduce
798+
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
799+
SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
800+
797801
- Issue #5033: Fix building of the sqlite3 extension module when the
798802
SQLite library version has "beta" in it. Patch by Andreas Pelme.
799803

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
@@ -625,6 +625,7 @@ ac_includes_default="\
625625
ac_subst_vars='LTLIBOBJS
626626
SRCDIRS
627627
THREADHEADERS
628+
EXT_SUFFIX
628629
SOABI
629630
LIBC
630631
LIBM
@@ -652,7 +653,7 @@ CCSHARED
652653
BLDSHARED
653654
LDCXXSHARED
654655
LDSHARED
655-
SO
656+
SHLIB_SUFFIX
656657
LIBTOOL_CRUFT
657658
OTHER_LIBTOOL_OPT
658659
UNIVERSAL_ARCH_FLAGS
@@ -8392,6 +8393,25 @@ esac
83928393

83938394

83948395

8396+
# SHLIB_SUFFIX is the extension of shared libraries `(including the dot!)
8397+
# -- usually .so, .sl on HP-UX, .dll on Cygwin
8398+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the extension of shared libraries" >&5
8399+
$as_echo_n "checking the extension of shared libraries... " >&6; }
8400+
if test -z "$SHLIB_SUFFIX"; then
8401+
case $ac_sys_system in
8402+
hp*|HP*)
8403+
case `uname -m` in
8404+
ia64) SHLIB_SUFFIX=.so;;
8405+
*) SHLIB_SUFFIX=.sl;;
8406+
esac
8407+
;;
8408+
CYGWIN*) SHLIB_SUFFIX=.dll;;
8409+
*) SHLIB_SUFFIX=.so;;
8410+
esac
8411+
fi
8412+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLIB_SUFFIX" >&5
8413+
$as_echo "$SHLIB_SUFFIX" >&6; }
8414+
83958415
# LDSHARED is the ld *command* used to create shared library
83968416
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
83978417
# (Shared libraries in this instance are shared modules to be loaded into
@@ -13685,51 +13705,20 @@ SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
1368513705
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
1368613706
$as_echo "$SOABI" >&6; }
1368713707

13708+
13709+
case $ac_sys_system in
13710+
Linux*|GNU*)
13711+
EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX};;
13712+
*)
13713+
EXT_SUFFIX=${SHLIB_SUFFIX};;
13714+
esac
13715+
1368813716
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking LDVERSION" >&5
1368913717
$as_echo_n "checking LDVERSION... " >&6; }
1369013718
LDVERSION='$(VERSION)$(ABIFLAGS)'
1369113719
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDVERSION" >&5
1369213720
$as_echo "$LDVERSION" >&6; }
1369313721

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

0 commit comments

Comments
 (0)
X Tutup