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

Unified Diff: Lib/sysconfig.py

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 2 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/plat-generic/regen ('k') | Lib/test/test_capi.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/sysconfig.py Thu Dec 27 23:52:36 2012 +0200
+++ b/Lib/sysconfig.py Thu Dec 27 17:35:12 2012 -0500
@@ -166,6 +166,10 @@
_INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include'
_INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}/.'
+ # GCC(mingw) use posix build system
+ if os.name == "nt" and sys.version.upper().find('GCC') >= 0:
+ _INSTALL_SCHEMES['nt']['include'] = '{srcdir}/Include'
+ _INSTALL_SCHEMES['nt']['platinclude'] = '{projectbase}/.'
def _subst_vars(s, local_vars):
try:
@@ -390,29 +394,7 @@
if _PYTHON_BUILD:
vars['LDSHARED'] = vars['BLDSHARED']
- # There's a chicken-and-egg situation on OS X with regards to the
- # _sysconfigdata module after the changes introduced by #15298:
- # get_config_vars() is called by get_platform() as part of the
- # `make pybuilddir.txt` target -- which is a precursor to the
- # _sysconfigdata.py module being constructed. Unfortunately,
- # get_config_vars() eventually calls _init_posix(), which attempts
- # to import _sysconfigdata, which we won't have built yet. In order
- # for _init_posix() to work, if we're on Darwin, just mock up the
- # _sysconfigdata module manually and populate it with the build vars.
- # This is more than sufficient for ensuring the subsequent call to
- # get_platform() succeeds.
- name = '_sysconfigdata'
- if 'darwin' in sys.platform:
- import imp
- module = imp.new_module(name)
- module.build_time_vars = vars
- sys.modules[name] = module
-
- pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3])
- if hasattr(sys, "gettotalrefcount"):
- pybuilddir += '-pydebug'
- os.makedirs(pybuilddir, exist_ok=True)
- destfile = os.path.join(pybuilddir, name + '.py')
+ destfile = os.path.join(os.path.dirname(__file__), '_sysconfigdata.py')
with open(destfile, 'w', encoding='utf8') as f:
f.write('# system configuration generated and used by'
@@ -420,10 +402,6 @@
f.write('build_time_vars = ')
pprint.pprint(vars, stream=f)
- # Create file used for sys.path fixup -- see Modules/getpath.c
- with open('pybuilddir.txt', 'w', encoding='ascii') as f:
- f.write(pybuilddir)
-
def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# _sysconfigdata is generated at build time, see _generate_posix_vars()
@@ -480,7 +458,8 @@
def get_config_h_filename():
"""Return the path of pyconfig.h."""
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
@@ -551,9 +530,16 @@
# sys.abiflags may not be defined on all platforms.
_CONFIG_VARS['abiflags'] = ''
- if os.name in ('nt', 'os2'):
+ # GCC(mingw) use posix build system
+ posix_build = False
+ if os.name == 'posix':
+ posix_build = True
+ else:
+ if os.name == 'nt' and sys.version.upper().find('GCC') >= 0:
+ posix_build = True
+ if os.name in ('nt', 'os2') and not posix_build:
_init_non_posix(_CONFIG_VARS)
- if os.name == 'posix':
+ if posix_build:
_init_posix(_CONFIG_VARS)
# Setting 'userbase' is done below the call to the
# init function to enable using 'get_config_var' in
@@ -562,7 +548,7 @@
# 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
« no previous file with comments | « Lib/plat-generic/regen ('k') | Lib/test/test_capi.py » ('j') | no next file with comments »

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