Merged revisions 77759,77761 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77759 | tarek.ziade | 2010-01-26 22:21:54 +0100 (Tue, 26 Jan 2010) | 1 line reintroduced the names in Distutils for APIs that were relocated ........ r77761 | tarek.ziade | 2010-01-26 23:46:15 +0100 (Tue, 26 Jan 2010) | 1 line added local get_platform/set_platform APIs in distutils.sysconfig ........
This commit is contained in:
parent
edacea30e4
commit
8b441d0dcd
|
@ -6,8 +6,8 @@ distribution)."""
|
|||
__revision__ = "$Id$"
|
||||
|
||||
import os
|
||||
from sysconfig import get_platform
|
||||
|
||||
from distutils.util import get_platform
|
||||
from distutils.core import Command
|
||||
from distutils.errors import DistutilsPlatformError, DistutilsOptionError
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@ __revision__ = "$Id$"
|
|||
|
||||
import os
|
||||
|
||||
from sysconfig import get_python_version, get_platform
|
||||
from sysconfig import get_python_version
|
||||
|
||||
from distutils.util import get_platform
|
||||
from distutils.core import Command
|
||||
from distutils.dir_util import remove_tree, ensure_relative
|
||||
from distutils.errors import DistutilsPlatformError
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
"""
|
||||
Implements the bdist_msi command.
|
||||
"""
|
||||
import sys, os
|
||||
from sysconfig import get_python_version
|
||||
|
||||
import sys, os
|
||||
from distutils.core import Command
|
||||
|
@ -15,6 +17,7 @@ from distutils.version import StrictVersion
|
|||
from distutils.errors import DistutilsOptionError
|
||||
from distutils.util import get_platform
|
||||
from distutils import log
|
||||
|
||||
import msilib
|
||||
from msilib import schema, sequence, text
|
||||
from msilib import Directory, Feature, Dialog, add_data
|
||||
|
|
|
@ -8,12 +8,13 @@ __revision__ = "$Id$"
|
|||
import sys
|
||||
import os
|
||||
|
||||
from sysconfig import get_python_version, get_platform
|
||||
from sysconfig import get_python_version
|
||||
|
||||
from distutils.core import Command
|
||||
from distutils.dir_util import remove_tree
|
||||
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
|
||||
from distutils import log
|
||||
from distutils.util import get_platform
|
||||
|
||||
class bdist_wininst(Command):
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ Implements the Distutils 'build' command."""
|
|||
__revision__ = "$Id$"
|
||||
|
||||
import sys, os
|
||||
from sysconfig import get_platform
|
||||
|
||||
from distutils.util import get_platform
|
||||
from distutils.core import Command
|
||||
from distutils.errors import DistutilsOptionError
|
||||
|
||||
|
|
|
@ -9,14 +9,12 @@ __revision__ = "$Id$"
|
|||
import sys, os, re
|
||||
from warnings import warn
|
||||
|
||||
from sysconfig import get_platform
|
||||
|
||||
from distutils.util import get_platform
|
||||
from distutils.core import Command
|
||||
from distutils.errors import *
|
||||
from distutils.ccompiler import customize_compiler
|
||||
from distutils.dep_util import newer_group
|
||||
from distutils.extension import Extension
|
||||
|
||||
from distutils import log
|
||||
|
||||
# this keeps compatibility from 2.3 to 2.5
|
||||
|
|
|
@ -7,15 +7,14 @@ __revision__ = "$Id$"
|
|||
import sys
|
||||
import os
|
||||
|
||||
from sysconfig import (get_config_vars, get_platform, get_paths, get_path,
|
||||
get_config_var)
|
||||
from sysconfig import get_config_vars, get_paths, get_path, get_config_var
|
||||
|
||||
from distutils import log
|
||||
from distutils.core import Command
|
||||
from distutils.debug import DEBUG
|
||||
from distutils.errors import DistutilsPlatformError
|
||||
from distutils.file_util import write_file
|
||||
from distutils.util import convert_path, change_root
|
||||
from distutils.util import convert_path, change_root, get_platform
|
||||
from distutils.errors import DistutilsOptionError
|
||||
|
||||
def _subst_vars(s, local_vars):
|
||||
|
|
|
@ -23,9 +23,9 @@ from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
|
|||
CompileError, LibError, LinkError)
|
||||
from distutils.ccompiler import CCompiler, gen_lib_options
|
||||
from distutils import log
|
||||
import winreg
|
||||
from distutils.util import get_platform
|
||||
|
||||
_sysconfig = __import__('sysconfig')
|
||||
import winreg
|
||||
|
||||
RegOpenKeyEx = winreg.OpenKeyEx
|
||||
RegEnumKey = winreg.EnumKey
|
||||
|
@ -327,7 +327,7 @@ class MSVCCompiler(CCompiler) :
|
|||
# multi-init means we would need to check platform same each time...
|
||||
assert not self.initialized, "don't init multiple times"
|
||||
if plat_name is None:
|
||||
plat_name = _sysconfig.get_platform()
|
||||
plat_name = get_platform()
|
||||
# sanity check for platforms to prevent obscure errors later.
|
||||
ok_plats = 'win32', 'win-amd64', 'win-ia64'
|
||||
if plat_name not in ok_plats:
|
||||
|
@ -348,12 +348,12 @@ class MSVCCompiler(CCompiler) :
|
|||
# On AMD64, 'vcvars32.bat amd64' is a native build env; to cross
|
||||
# compile use 'x86' (ie, it runs the x86 compiler directly)
|
||||
# No idea how itanium handles this, if at all.
|
||||
if plat_name == _sysconfig.get_platform() or plat_name == 'win32':
|
||||
if plat_name == get_platform() or plat_name == 'win32':
|
||||
# native build or cross-compile to win32
|
||||
plat_spec = PLAT_TO_VCVARS[plat_name]
|
||||
else:
|
||||
# cross compile from win32 -> some 64bit
|
||||
plat_spec = PLAT_TO_VCVARS[_sysconfig.get_platform()] + '_' + \
|
||||
plat_spec = PLAT_TO_VCVARS[get_platform()] + '_' + \
|
||||
PLAT_TO_VCVARS[plat_name]
|
||||
|
||||
vc_env = query_vcvarsall(VERSION, plat_spec)
|
||||
|
|
|
@ -25,6 +25,15 @@ from distutils.errors import DistutilsPlatformError
|
|||
# to avoid this module to shadow it
|
||||
_sysconfig = __import__('sysconfig')
|
||||
|
||||
# names defined here to keep backward compatibility
|
||||
# for APIs that were relocated
|
||||
get_python_version = _sysconfig.get_python_version
|
||||
get_config_h_filename = _sysconfig.get_config_h_filename
|
||||
parse_config_h = _sysconfig.parse_config_h
|
||||
get_config_vars = _sysconfig.get_config_vars
|
||||
get_config_var = _sysconfig.get_config_var
|
||||
from distutils.ccompiler import customize_compiler
|
||||
|
||||
_DEPRECATION_MSG = ("distutils.sysconfig.%s is deprecated. "
|
||||
"Use the APIs provided by the sysconfig module instead")
|
||||
|
||||
|
|
|
@ -90,125 +90,12 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
|
|||
def _get_uname(self):
|
||||
return self._uname
|
||||
|
||||
def _test_get_platform(self):
|
||||
|
||||
# windows XP, 32bits
|
||||
os.name = 'nt'
|
||||
sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
|
||||
'[MSC v.1310 32 bit (Intel)]')
|
||||
sys.platform = 'win32'
|
||||
self.assertEquals(get_platform(), 'win32')
|
||||
|
||||
# windows XP, amd64
|
||||
os.name = 'nt'
|
||||
sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
|
||||
'[MSC v.1310 32 bit (Amd64)]')
|
||||
sys.platform = 'win32'
|
||||
self.assertEquals(get_platform(), 'win-amd64')
|
||||
|
||||
# windows XP, itanium
|
||||
os.name = 'nt'
|
||||
sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
|
||||
'[MSC v.1310 32 bit (Itanium)]')
|
||||
sys.platform = 'win32'
|
||||
self.assertEquals(get_platform(), 'win-ia64')
|
||||
|
||||
# macbook
|
||||
os.name = 'posix'
|
||||
sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
|
||||
'\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
|
||||
sys.platform = 'darwin'
|
||||
self._set_uname(('Darwin', 'macziade', '8.11.1',
|
||||
('Darwin Kernel Version 8.11.1: '
|
||||
'Wed Oct 10 18:23:28 PDT 2007; '
|
||||
'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
|
||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
|
||||
'-fwrapv -O3 -Wall -Wstrict-prototypes')
|
||||
|
||||
maxsize = sys.maxsize
|
||||
try:
|
||||
sys.maxsize = 2147483647
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-ppc')
|
||||
sys.maxsize = 9223372036854775807
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-ppc64')
|
||||
finally:
|
||||
sys.maxsize = maxsize
|
||||
|
||||
|
||||
self._set_uname(('Darwin', 'macziade', '8.11.1',
|
||||
('Darwin Kernel Version 8.11.1: '
|
||||
'Wed Oct 10 18:23:28 PDT 2007; '
|
||||
'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
|
||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
|
||||
'-fwrapv -O3 -Wall -Wstrict-prototypes')
|
||||
|
||||
maxsize = sys.maxsize
|
||||
try:
|
||||
sys.maxsize = 2147483647
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-i386')
|
||||
sys.maxsize = 9223372036854775807
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-x86_64')
|
||||
finally:
|
||||
sys.maxsize = maxsize
|
||||
|
||||
# macbook with fat binaries (fat, universal or fat64)
|
||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
|
||||
get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot '
|
||||
'/Developer/SDKs/MacOSX10.4u.sdk '
|
||||
'-fno-strict-aliasing -fno-common '
|
||||
'-dynamic -DNDEBUG -g -O3')
|
||||
|
||||
self.assertEquals(get_platform(), 'macosx-10.4-fat')
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot '
|
||||
'/Developer/SDKs/MacOSX10.4u.sdk '
|
||||
'-fno-strict-aliasing -fno-common '
|
||||
'-dynamic -DNDEBUG -g -O3')
|
||||
|
||||
self.assertEquals(get_platform(), 'macosx-10.4-intel')
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot '
|
||||
'/Developer/SDKs/MacOSX10.4u.sdk '
|
||||
'-fno-strict-aliasing -fno-common '
|
||||
'-dynamic -DNDEBUG -g -O3')
|
||||
self.assertEquals(get_platform(), 'macosx-10.4-fat3')
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
|
||||
'/Developer/SDKs/MacOSX10.4u.sdk '
|
||||
'-fno-strict-aliasing -fno-common '
|
||||
'-dynamic -DNDEBUG -g -O3')
|
||||
self.assertEquals(get_platform(), 'macosx-10.4-universal')
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot '
|
||||
'/Developer/SDKs/MacOSX10.4u.sdk '
|
||||
'-fno-strict-aliasing -fno-common '
|
||||
'-dynamic -DNDEBUG -g -O3')
|
||||
|
||||
self.assertEquals(get_platform(), 'macosx-10.4-fat64')
|
||||
|
||||
for arch in ('ppc', 'i386', 'x86_64', 'ppc64'):
|
||||
get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
|
||||
'/Developer/SDKs/MacOSX10.4u.sdk '
|
||||
'-fno-strict-aliasing -fno-common '
|
||||
'-dynamic -DNDEBUG -g -O3'%(arch,))
|
||||
|
||||
self.assertEquals(get_platform(), 'macosx-10.4-%s'%(arch,))
|
||||
|
||||
# linux debian sarge
|
||||
os.name = 'posix'
|
||||
sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) '
|
||||
'\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]')
|
||||
sys.platform = 'linux2'
|
||||
self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7',
|
||||
'#1 Mon Apr 30 17:25:38 CEST 2007', 'i686'))
|
||||
|
||||
self.assertEquals(get_platform(), 'linux-i686')
|
||||
|
||||
# XXX more platforms to tests here
|
||||
def test_get_platform(self):
|
||||
platform = util.get_platform()
|
||||
self.assertEquals(platform, get_platform())
|
||||
util.set_platform('MyOwnPlatform')
|
||||
self.assertEquals('MyOwnPlatform', util.get_platform())
|
||||
util.set_platform(platform)
|
||||
|
||||
def test_convert_path(self):
|
||||
# linux/mac
|
||||
|
|
|
@ -16,6 +16,27 @@ from distutils.version import LooseVersion
|
|||
from distutils.errors import DistutilsByteCompileError
|
||||
|
||||
_sysconfig = __import__('sysconfig')
|
||||
_PLATFORM = None
|
||||
|
||||
def get_platform():
|
||||
"""Return a string that identifies the current platform.
|
||||
|
||||
By default, will return the value returned by sysconfig.get_platform(),
|
||||
but it can be changed by calling set_platform().
|
||||
"""
|
||||
global _PLATFORM
|
||||
if _PLATFORM is None:
|
||||
_PLATFORM = _sysconfig.get_platform()
|
||||
return _PLATFORM
|
||||
|
||||
def set_platform(identifier):
|
||||
"""Sets the platform string identifier returned by get_platform().
|
||||
|
||||
Note that this change doesn't impact the value returned by
|
||||
sysconfig.get_platform() and is local to Distutils
|
||||
"""
|
||||
global _PLATFORM
|
||||
_PLATFORM = identifier
|
||||
|
||||
def convert_path(pathname):
|
||||
"""Return 'pathname' as a name that will work on the native filesystem.
|
||||
|
|
|
@ -135,6 +135,25 @@ class TestSysConfig(unittest.TestCase):
|
|||
sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
|
||||
'\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
|
||||
sys.platform = 'darwin'
|
||||
self._set_uname(('Darwin', 'macziade', '8.11.1',
|
||||
('Darwin Kernel Version 8.11.1: '
|
||||
'Wed Oct 10 18:23:28 PDT 2007; '
|
||||
'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
|
||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
|
||||
|
||||
get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
|
||||
'-fwrapv -O3 -Wall -Wstrict-prototypes')
|
||||
|
||||
maxsize = sys.maxsize
|
||||
try:
|
||||
sys.maxsize = 2147483647
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-ppc')
|
||||
sys.maxsize = 9223372036854775807
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-ppc64')
|
||||
finally:
|
||||
sys.maxsize = maxsize
|
||||
|
||||
|
||||
self._set_uname(('Darwin', 'macziade', '8.11.1',
|
||||
('Darwin Kernel Version 8.11.1: '
|
||||
'Wed Oct 10 18:23:28 PDT 2007; '
|
||||
|
@ -145,7 +164,14 @@ class TestSysConfig(unittest.TestCase):
|
|||
get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
|
||||
'-fwrapv -O3 -Wall -Wstrict-prototypes')
|
||||
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-i386')
|
||||
maxsize = sys.maxsize
|
||||
try:
|
||||
sys.maxsize = 2147483647
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-i386')
|
||||
sys.maxsize = 9223372036854775807
|
||||
self.assertEquals(get_platform(), 'macosx-10.3-x86_64')
|
||||
finally:
|
||||
sys.maxsize = maxsize
|
||||
|
||||
# macbook with fat binaries (fat, universal or fat64)
|
||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
|
||||
|
|
Loading…
Reference in New Issue