Skip to content

Commit 514e9d0

Browse files
authored
Merge pull request #69 from pypa/feature/pkgsrc-compat
Allow pkgsrc to monkeypatch settings instead of relying on patches.
2 parents 46c2e34 + 3953950 commit 514e9d0

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

distutils/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616

1717
try:
18-
# Allow Debian (only) to customize system behavior.
19-
# Ref pypa/distutils#2. This hook is deprecated and
20-
# no other environments should use it.
18+
# Allow Debian and pkgsrc (only) to customize system
19+
# behavior. Ref pypa/distutils#2 and pypa/distutils#16.
20+
# This hook is deprecated and no other environments
21+
# should use it.
2122
importlib.import_module('_distutils_system_mod')
2223
except ImportError:
2324
pass

distutils/sysconfig.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,24 @@ def get_config_h_filename():
280280
return os.path.join(inc_dir, 'pyconfig.h')
281281

282282

283+
# Allow this value to be patched by pkgsrc. Ref pypa/distutils#16.
284+
_makefile_tmpl = 'config-{python_ver}{build_flags}{multiarch}'
285+
286+
283287
def get_makefile_filename():
284288
"""Return full pathname of installed Makefile from the Python build."""
285289
if python_build:
286290
return os.path.join(_sys_home or project_base, "Makefile")
287291
lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
288-
config_file = 'config-{}{}'.format(get_python_version(), build_flags)
289-
if hasattr(sys.implementation, '_multiarch'):
290-
config_file += '-%s' % sys.implementation._multiarch
292+
multiarch = (
293+
'-%s' % sys.implementation._multiarch
294+
if hasattr(sys.implementation, '_multiarch') else ''
295+
)
296+
config_file = _makefile_tmpl.format(
297+
python_ver=get_python_version(),
298+
build_flags=build_flags,
299+
multiarch=multiarch,
300+
)
291301
return os.path.join(lib_dir, config_file, 'Makefile')
292302

293303

@@ -459,15 +469,21 @@ def expand_makefile_vars(s, vars):
459469

460470
_config_vars = None
461471

472+
473+
_sysconfig_name_tmpl = '_sysconfigdata_{abi}_{platform}_{multiarch}'
474+
475+
462476
def _init_posix():
463477
"""Initialize the module as appropriate for POSIX systems."""
464478
# _sysconfigdata is generated at build time, see the sysconfig module
465-
name = os.environ.get('_PYTHON_SYSCONFIGDATA_NAME',
466-
'_sysconfigdata_{abi}_{platform}_{multiarch}'.format(
467-
abi=sys.abiflags,
468-
platform=sys.platform,
469-
multiarch=getattr(sys.implementation, '_multiarch', ''),
470-
))
479+
name = os.environ.get(
480+
'_PYTHON_SYSCONFIGDATA_NAME',
481+
_sysconfig_name_tmpl.format(
482+
abi=sys.abiflags,
483+
platform=sys.platform,
484+
multiarch=getattr(sys.implementation, '_multiarch', ''),
485+
),
486+
)
471487
try:
472488
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
473489
except ImportError:

0 commit comments

Comments
 (0)