Skip to content

Commit

Permalink
Merge pull request #10 from pypa/bugfix/9-legacy-link-libpython
Browse files Browse the repository at this point in the history
Restore pythonlib support on older Pythons.
  • Loading branch information
jaraco authored Sep 2, 2020
2 parents 5ab258b + 97a8f11 commit 526b7fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from distutils.extension import Extension
from distutils.util import get_platform
from distutils import log
from . import py37compat

from site import USER_BASE

Expand Down Expand Up @@ -751,4 +752,4 @@ def get_libraries(self, ext):
ldversion = get_config_var('LDVERSION')
return ext.libraries + ['python' + ldversion]

return ext.libraries
return ext.libraries + py37compat.pythonlib()
30 changes: 30 additions & 0 deletions distutils/command/py37compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys


def _pythonlib_compat():
"""
On Python 3.7 and earlier, distutils would include the Python
library. See pypa/distutils#9.
"""
from distutils import sysconfig
if not sysconfig.get_config_var('Py_ENABLED_SHARED'):
return

yield 'python{}.{}{}'.format(
sys.hexversion >> 24,
(sys.hexversion >> 16) & 0xff,
sysconfig.get_config_var('ABIFLAGS'),
)


def compose(f1, f2):
return lambda *args, **kwargs: f1(f2(*args, **kwargs))


pythonlib = (
compose(list, _pythonlib_compat)
if sys.version_info < (3, 8)
and sys.platform != 'darwin'
and sys.platform[:3] != 'aix'
else list
)

0 comments on commit 526b7fe

Please sign in to comment.