Skip to content

Commit

Permalink
Merge pull request #69 from pypa/feature/pkgsrc-compat
Browse files Browse the repository at this point in the history
Allow pkgsrc to monkeypatch settings instead of relying on patches.
  • Loading branch information
jaraco committed Nov 18, 2021
2 parents 46c2e34 + 3953950 commit 514e9d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
7 changes: 4 additions & 3 deletions distutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@


try:
# Allow Debian (only) to customize system behavior.
# Ref pypa/distutils#2. This hook is deprecated and
# no other environments should use it.
# Allow Debian and pkgsrc (only) to customize system
# behavior. Ref pypa/distutils#2 and pypa/distutils#16.
# This hook is deprecated and no other environments
# should use it.
importlib.import_module('_distutils_system_mod')
except ImportError:
pass
34 changes: 25 additions & 9 deletions distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,24 @@ def get_config_h_filename():
return os.path.join(inc_dir, 'pyconfig.h')


# Allow this value to be patched by pkgsrc. Ref pypa/distutils#16.
_makefile_tmpl = 'config-{python_ver}{build_flags}{multiarch}'


def get_makefile_filename():
"""Return full pathname of installed Makefile from the Python build."""
if python_build:
return os.path.join(_sys_home or project_base, "Makefile")
lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
config_file = 'config-{}{}'.format(get_python_version(), build_flags)
if hasattr(sys.implementation, '_multiarch'):
config_file += '-%s' % sys.implementation._multiarch
multiarch = (
'-%s' % sys.implementation._multiarch
if hasattr(sys.implementation, '_multiarch') else ''
)
config_file = _makefile_tmpl.format(
python_ver=get_python_version(),
build_flags=build_flags,
multiarch=multiarch,
)
return os.path.join(lib_dir, config_file, 'Makefile')


Expand Down Expand Up @@ -459,15 +469,21 @@ def expand_makefile_vars(s, vars):

_config_vars = None


_sysconfig_name_tmpl = '_sysconfigdata_{abi}_{platform}_{multiarch}'


def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
# _sysconfigdata is generated at build time, see the sysconfig module
name = os.environ.get('_PYTHON_SYSCONFIGDATA_NAME',
'_sysconfigdata_{abi}_{platform}_{multiarch}'.format(
abi=sys.abiflags,
platform=sys.platform,
multiarch=getattr(sys.implementation, '_multiarch', ''),
))
name = os.environ.get(
'_PYTHON_SYSCONFIGDATA_NAME',
_sysconfig_name_tmpl.format(
abi=sys.abiflags,
platform=sys.platform,
multiarch=getattr(sys.implementation, '_multiarch', ''),
),
)
try:
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
except ImportError:
Expand Down

0 comments on commit 514e9d0

Please sign in to comment.