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

Side by Side Diff: Lib/sysconfig.py

Issue 17086: backport cross-build patches to the 2.7 branch
Patch Set: Created 6 years, 4 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Lib/plat-generic/regen ('k') | Makefile.pre.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Provide access to Python's configuration information. 1 """Provide access to Python's configuration information.
2 2
3 """ 3 """
4 import sys 4 import sys
5 import os 5 import os
6 from os.path import pardir, realpath 6 from os.path import pardir, realpath
7 7
8 _INSTALL_SCHEMES = { 8 _INSTALL_SCHEMES = {
9 'posix_prefix': { 9 'posix_prefix': {
10 'stdlib': '{base}/lib/python{py_version_short}', 10 'stdlib': '{base}/lib/python{py_version_short}',
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower(): 110 if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
111 _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir)) 111 _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir))
112 # PC/VS7.1 112 # PC/VS7.1
113 if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower(): 113 if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower():
114 _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir)) 114 _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
115 # PC/AMD64 115 # PC/AMD64
116 if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower(): 116 if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower():
117 _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir)) 117 _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
118 118
119 # set for cross builds
120 if "_PYTHON_PROJECT_BASE" in os.environ:
121 # the build directory for posix builds
122 _PROJECT_BASE = os.path.normpath(os.path.abspath("."))
119 def is_python_build(): 123 def is_python_build():
120 for fn in ("Setup.dist", "Setup.local"): 124 for fn in ("Setup.dist", "Setup.local"):
121 if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)): 125 if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)):
122 return True 126 return True
123 return False 127 return False
124 128
125 _PYTHON_BUILD = is_python_build() 129 _PYTHON_BUILD = is_python_build()
126 130
127 if _PYTHON_BUILD: 131 if _PYTHON_BUILD:
128 for scheme in ('posix_prefix', 'posix_home'): 132 for scheme in ('posix_prefix', 'posix_home'):
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 i = sys.version.find(prefix) 556 i = sys.version.find(prefix)
553 if i == -1: 557 if i == -1:
554 return sys.platform 558 return sys.platform
555 j = sys.version.find(")", i) 559 j = sys.version.find(")", i)
556 look = sys.version[i+len(prefix):j].lower() 560 look = sys.version[i+len(prefix):j].lower()
557 if look == 'amd64': 561 if look == 'amd64':
558 return 'win-amd64' 562 return 'win-amd64'
559 if look == 'itanium': 563 if look == 'itanium':
560 return 'win-ia64' 564 return 'win-ia64'
561 return sys.platform 565 return sys.platform
566
567 # Set for cross builds explicitly
568 if "_PYTHON_HOST_PLATFORM" in os.environ:
569 return os.environ["_PYTHON_HOST_PLATFORM"]
562 570
563 if os.name != "posix" or not hasattr(os, 'uname'): 571 if os.name != "posix" or not hasattr(os, 'uname'):
564 # XXX what about the architecture? NT is Intel or Alpha, 572 # XXX what about the architecture? NT is Intel or Alpha,
565 # Mac OS is M68k or PPC, etc. 573 # Mac OS is M68k or PPC, etc.
566 return sys.platform 574 return sys.platform
567 575
568 # Try to distinguish various flavours of Unix 576 # Try to distinguish various flavours of Unix
569 osname, host, release, version, machine = os.uname() 577 osname, host, release, version, machine = os.uname()
570 578
571 # Convert the OS name to lowercase, remove '/' characters 579 # Convert the OS name to lowercase, remove '/' characters
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 if sys.maxint >= 2**32: 692 if sys.maxint >= 2**32:
685 machine = 'ppc64' 693 machine = 'ppc64'
686 else: 694 else:
687 machine = 'ppc' 695 machine = 'ppc'
688 696
689 return "%s-%s-%s" % (osname, release, machine) 697 return "%s-%s-%s" % (osname, release, machine)
690 698
691 699
692 def get_python_version(): 700 def get_python_version():
693 return _PY_VERSION_SHORT 701 return _PY_VERSION_SHORT
OLDNEW
« no previous file with comments | « Lib/plat-generic/regen ('k') | Makefile.pre.in » ('j') | no next file with comments »

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