Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebbef6f

Browse files
committed
Issue 9877: expose sysconfig.get_makefile_filename() in the public API.
1 parent 18cc344 commit ebbef6f

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

Doc/library/sysconfig.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ Other functions
217217

218218
Return the path of :file:`pyconfig.h`.
219219

220+
.. function:: get_makefile_filename()
221+
222+
Return the path of :file:`Makefile`.
223+
220224
Using :mod:`sysconfig` as a script
221225
----------------------------------
222226

Lib/sysconfig.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@
55
import os
66
from os.path import pardir, realpath
77

8-
__all__ = ['parse_config_h', 'get_config_h_filename', 'get_scheme_names',
9-
'get_path_names', 'get_paths', 'get_path', 'get_config_vars',
10-
'get_config_var', 'get_platform', 'get_python_version']
8+
__all__ = [
9+
'get_config_h_filename',
10+
'get_config_var',
11+
'get_config_vars',
12+
'get_makefile_filename',
13+
'get_path',
14+
'get_path_names',
15+
'get_paths',
16+
'get_platform',
17+
'get_python_version',
18+
'get_scheme_names',
19+
'parse_config_h',
20+
]
1121

1222
_INSTALL_SCHEMES = {
1323
'posix_prefix': {
@@ -291,7 +301,7 @@ def _parse_makefile(filename, vars=None):
291301
return vars
292302

293303

294-
def _get_makefile_filename():
304+
def get_makefile_filename():
295305
if _PYTHON_BUILD:
296306
return os.path.join(_PROJECT_BASE, "Makefile")
297307
return os.path.join(get_path('stdlib'), "config", "Makefile")
@@ -300,7 +310,7 @@ def _get_makefile_filename():
300310
def _init_posix(vars):
301311
"""Initialize the module as appropriate for POSIX systems."""
302312
# load the installed Makefile:
303-
makefile = _get_makefile_filename()
313+
makefile = get_makefile_filename()
304314
try:
305315
_parse_makefile(makefile, vars)
306316
except IOError as e:

Lib/test/test_sysconfig.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ def test_get_config_h_filename(self):
234234
config_h = sysconfig.get_config_h_filename()
235235
self.assertTrue(os.path.isfile(config_h), config_h)
236236

237+
def test_get_makefile_filename(self):
238+
makefile = sysconfig.get_makefile_filename()
239+
self.assertTrue(os.path.isfile(makefile), makefile)
240+
237241
def test_get_scheme_names(self):
238242
wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user',
239243
'posix_home', 'posix_prefix', 'posix_user')

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Core and Builtins
5555
Library
5656
-------
5757

58+
- Issue #9877: Expose sysconfig.get_makefile_filename()
59+
5860
- logging: Added hasHandlers() method to Logger and LoggerAdapter.
5961

6062
- Issue #1686: Fix string.Template when overriding the pattern attribute.

0 commit comments

Comments
 (0)