Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(131)

Unified Diff: Lib/distutils/sysconfig.py

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/distutils/cygwinccompiler.py ('k') | Lib/distutils/tests/support.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/distutils/sysconfig.py Mon Dec 17 20:46:29 2012 +0100
+++ b/Lib/distutils/sysconfig.py Tue Dec 18 21:47:22 2012 -0500
@@ -90,8 +90,9 @@
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
if prefix is None:
- prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
- if os.name == "posix":
+ prefix = plat_specific and BASE_PREFIX or BASE_EXEC_PREFIX
+ # GCC(mingw): os.name is "nt" but build system is posix
+ if os.name == "posix" or sys.version.upper().find('GCC') >= 0:
if python_build:
# Assume the executable is in the build directory. The
# pyconfig.h file should be in the same directory. Since
@@ -106,6 +107,7 @@
else:
incdir = os.path.join(get_config_var('srcdir'), 'Include')
return os.path.normpath(incdir)
+ # TODO mingw build as get_python_version() return dot separated value
python_dir = 'python' + get_python_version() + build_flags
return os.path.join(prefix, "include", python_dir)
elif os.name == "nt":
@@ -132,13 +134,16 @@
If 'prefix' is supplied, use it instead of sys.base_prefix or
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
+ # GCC(mingw): os.name is "nt" but build system is posix
+ posix_build = os.name == "posix" or sys.version.upper().find('GCC') >= 0
+
if prefix is None:
if standard_lib:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX
- if os.name == "posix":
+ if posix_build:
libpython = os.path.join(prefix,
"lib", "python" + get_python_version())
if standard_lib:
@@ -170,8 +175,14 @@
Mainly needed on Unix, so we can plug in the information that
varies across Unices and is stored in Python's Makefile.
+
+ NOTE (known limitation of python build/install system):
+ In cross-build environment make macros like CC and LDSHARED
+ contain cross-compiler/linker instead of host compiler/linker.
"""
+ posix_build = None
if compiler.compiler_type == "unix":
+ posix_build = True
if sys.platform == "darwin":
# Perform first-time customization of compiler-related
# config vars on OS X now that we know we need a compiler.
@@ -186,7 +197,12 @@
import _osx_support
_osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
+ elif compiler.compiler_type == "mingw32":
+ # GCC(mingw): if build system is posix
+ if sys.version.upper().find('GCC') >= 0:
+ posix_build = True
+ if posix_build == True:
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
@@ -234,7 +250,8 @@
def get_config_h_filename():
"""Return full pathname of installed pyconfig.h file."""
if python_build:
- if os.name == "nt":
+ # GCC(mingw): os.name is "nt" but build system is posix
+ if os.name == "nt" and sys.version.upper().find('GCC') < 0:
inc_dir = os.path.join(_sys_home or project_base, "PC")
else:
inc_dir = _sys_home or project_base
@@ -475,6 +492,11 @@
def _init_nt():
"""Initialize the module as appropriate for NT"""
+ if sys.version.upper().find('GCC') >= 0:
+ # GCC(mingw) use posix build system
+ # FIXME: may be modification has to be in get_config_vars ?
+ _init_posix()
+ return
g = {}
# set basic install directories
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
@@ -519,6 +541,7 @@
With arguments, return a list of values that result from looking up
each argument in the configuration variable dictionary.
"""
+
global _config_vars
if _config_vars is None:
func = globals().get("_init_" + os.name)
@@ -533,9 +556,12 @@
_config_vars['prefix'] = PREFIX
_config_vars['exec_prefix'] = EXEC_PREFIX
+ # GCC(mingw): os.name is "nt" but build system is posix
+ posix_build = os.name == "posix" or sys.version.upper().find('GCC') >= 0
+
# Always convert srcdir to an absolute path
srcdir = _config_vars.get('srcdir', project_base)
- if os.name == 'posix':
+ if posix_build:
if python_build:
# If srcdir is a relative path (typically '.' or '..')
# then it should be interpreted relative to the directory
@@ -554,7 +580,7 @@
# Normally it is relative to the build directory. However, during
# testing, for example, we might be running a non-installed python
# from a different directory.
- if python_build and os.name == "posix":
+ if python_build and posix_build:
base = os.path.dirname(os.path.abspath(sys.executable))
if (not os.path.isabs(_config_vars['srcdir']) and
base != os.getcwd()):
« no previous file with comments | « Lib/distutils/cygwinccompiler.py ('k') | Lib/distutils/tests/support.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+