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

Skip to content

Commit c14fa30

Browse files
committed
Patch #103279: sysconfig.py always looks for versions of files in
sys.prefix + 'config/Makefile'. When building Python for the first time, these files aren't there, so the files from the build tree have to be used instead; this file adds an entry point for specifying that the build tree files should be used. (Perhaps 'set_python_build' should should be preceded with an underscore?)
1 parent 846d6db commit c14fa30

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

Lib/distutils/sysconfig.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@
1919
PREFIX = os.path.normpath(sys.prefix)
2020
EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
2121

22+
# Boolean; if it's true, we're still building Python, so
23+
# we use different (hard-wired) directories.
24+
25+
python_build = 0
26+
27+
def set_python_build():
28+
"""Set the python_build flag to true; this means that we're
29+
building Python itself. Only called from the setup.py script
30+
shipped with Python.
31+
"""
32+
33+
global python_build
34+
python_build = 1
2235

2336
def get_python_inc(plat_specific=0, prefix=None):
2437
"""Return the directory containing installed Python header files.
@@ -34,6 +47,8 @@ def get_python_inc(plat_specific=0, prefix=None):
3447
if prefix is None:
3548
prefix = (plat_specific and EXEC_PREFIX or PREFIX)
3649
if os.name == "posix":
50+
if python_build:
51+
return "Include/"
3752
return os.path.join(prefix, "include", "python" + sys.version[:3])
3853
elif os.name == "nt":
3954
return os.path.join(prefix, "Include") # include or Include?
@@ -119,12 +134,15 @@ def customize_compiler (compiler):
119134

120135
def get_config_h_filename():
121136
"""Return full pathname of installed config.h file."""
122-
inc_dir = get_python_inc(plat_specific=1)
137+
if python_build: inc_dir = '.'
138+
else: inc_dir = get_python_inc(plat_specific=1)
123139
return os.path.join(inc_dir, "config.h")
124140

125141

126142
def get_makefile_filename():
127143
"""Return full pathname of installed Makefile from the Python build."""
144+
if python_build:
145+
return './Modules/Makefile'
128146
lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
129147
return os.path.join(lib_dir, "config", "Makefile")
130148

0 commit comments

Comments
 (0)