Skip to content

Commit 62ed952

Browse files
committed
sysconfig: use get_makefile_filename() from stdlib sysconfig
Instead of guessing the filename just refer to the stdlib. This also removes the "_makefile_tmpl" hook added in #16, but 1) It was never implemented by the distro requesting it from what I can see: https://github.com/NetBSD/pkgsrc/blob/586097714897b1b4d4a9/devel/py-setuptools/Makefile#L28 2) The stdlib version should return a proper result as it is patched by the distro requesting the change: https://github.com/NetBSD/pkgsrc/blob/6efa5763ec447864a7d4/lang/python38/patches/patch-Lib_sysconfig.py Also adds a small test checking that the file exists on Unix platforms
1 parent f56c3bf commit 62ed952

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

distutils/sysconfig.py

+1-17
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,9 @@ def get_config_h_filename():
281281

282282

283283

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

304288

305289
def parse_config_h(fp, g=None):

distutils/tests/test_sysconfig.py

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ def test_get_config_h_filename(self):
3838
config_h = sysconfig.get_config_h_filename()
3939
self.assertTrue(os.path.isfile(config_h), config_h)
4040

41+
@unittest.skipIf(sys.platform == 'win32',
42+
'Makefile only exists on Unix like systems')
43+
def test_get_makefile_filename(self):
44+
makefile = sysconfig.get_makefile_filename()
45+
self.assertTrue(os.path.isfile(makefile), makefile)
46+
4147
def test_get_python_lib(self):
4248
# XXX doesn't work on Linux when Python was never installed before
4349
#self.assertTrue(os.path.isdir(lib_dir), lib_dir)

0 commit comments

Comments
 (0)