Skip to content

Commit 35f3a2c

Browse files
committed
1 parent e4ea994 commit 35f3a2c

6 files changed

Lines changed: 430 additions & 333 deletions

File tree

Lib/distutils/tests/test_build_ext.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ def test_get_outputs(self):
323323
finally:
324324
os.chdir(old_wd)
325325
self.assertTrue(os.path.exists(so_file))
326-
self.assertEquals(os.path.splitext(so_file)[-1],
327-
sysconfig.get_config_var('SO'))
326+
so_ext = sysconfig.get_config_var('SO')
327+
self.assertTrue(so_file.endswith(so_ext))
328328
so_dir = os.path.dirname(so_file)
329329
self.assertEquals(so_dir, other_tmp_dir)
330330

@@ -333,8 +333,7 @@ def test_get_outputs(self):
333333
cmd.run()
334334
so_file = cmd.get_outputs()[0]
335335
self.assertTrue(os.path.exists(so_file))
336-
self.assertEquals(os.path.splitext(so_file)[-1],
337-
sysconfig.get_config_var('SO'))
336+
self.assertTrue(so_file.endswith(so_ext))
338337
so_dir = os.path.dirname(so_file)
339338
self.assertEquals(so_dir, cmd.build_lib)
340339

Makefile.pre.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ LINKCC= @LINKCC@
3535
AR= @AR@
3636
RANLIB= @RANLIB@
3737
SVNVERSION= @SVNVERSION@
38+
SOABI= @SOABI@
3839

3940
GNULD= @GNULD@
4041

@@ -559,6 +560,11 @@ Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
559560
Modules/python.o: $(srcdir)/Modules/python.c
560561
$(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Modules/python.c
561562

563+
Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
564+
$(CC) -c $(PY_CORE_CFLAGS) \
565+
-DSOABI='"$(SOABI)"' \
566+
-o $@ $(srcdir)/Python/dynload_shlib.c
567+
562568
$(IO_OBJS): $(IO_H)
563569

564570
# Use a stamp file to prevent make -j invoking pgen twice

Python/dynload_shlib.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,34 @@
3030
#define LEAD_UNDERSCORE ""
3131
#endif
3232

33+
/* The .so extension module ABI tag, supplied by the Makefile via
34+
Makefile.pre.in and configure. This is used to discriminate between
35+
incompatible .so files so that extensions for different Python builds can
36+
live in the same directory. E.g. foomodule.cpython-32.so
37+
*/
3338

3439
const struct filedescr _PyImport_DynLoadFiletab[] = {
3540
#ifdef __CYGWIN__
3641
{".dll", "rb", C_EXTENSION},
3742
{"module.dll", "rb", C_EXTENSION},
38-
#else
43+
#else /* !__CYGWIN__ */
3944
#if defined(PYOS_OS2) && defined(PYCC_GCC)
4045
{".pyd", "rb", C_EXTENSION},
4146
{".dll", "rb", C_EXTENSION},
42-
#else
47+
#else /* !(defined(PYOS_OS2) && defined(PYCC_GCC)) */
4348
#ifdef __VMS
4449
{".exe", "rb", C_EXTENSION},
4550
{".EXE", "rb", C_EXTENSION},
4651
{"module.exe", "rb", C_EXTENSION},
4752
{"MODULE.EXE", "rb", C_EXTENSION},
48-
#else
53+
#else /* !__VMS */
54+
{"." SOABI ".so", "rb", C_EXTENSION},
4955
{".so", "rb", C_EXTENSION},
56+
{"module." SOABI ".so", "rb", C_EXTENSION},
5057
{"module.so", "rb", C_EXTENSION},
51-
#endif
52-
#endif
53-
#endif
58+
#endif /* __VMS */
59+
#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */
60+
#endif /* __CYGWIN__ */
5461
{0, 0}
5562
};
5663

0 commit comments

Comments
 (0)