Commit 54ddd239 authored by Phillip J. Eby's avatar Phillip J. Eby

Split ``get_platform()`` into ``get_supported_platform()`` and

``get_build_platform()`` to work around a Mac versioning problem that caused
the behavior of ``compatible_platforms()`` to be platform specific.
parent 9d89299f
...@@ -18,7 +18,7 @@ from sets import ImmutableSet ...@@ -18,7 +18,7 @@ from sets import ImmutableSet
from os import utime, rename, unlink # capture these to bypass sandboxing from os import utime, rename, unlink # capture these to bypass sandboxing
from os import open as os_open from os import open as os_open
def _get_max_platform(plat): def get_supported_platform():
"""Return this platform's maximum compatible version. """Return this platform's maximum compatible version.
distutils.util.get_platform() normally reports the minimum version distutils.util.get_platform() normally reports the minimum version
...@@ -31,7 +31,7 @@ def _get_max_platform(plat): ...@@ -31,7 +31,7 @@ def _get_max_platform(plat):
If this condition occurs for any other platform with a version in its If this condition occurs for any other platform with a version in its
platform strings, this function should be extended accordingly. platform strings, this function should be extended accordingly.
""" """
m = macosVersionString.match(plat) plat = get_build_platform(); m = macosVersionString.match(plat)
if m is not None and sys.platform == "darwin": if m is not None and sys.platform == "darwin":
try: try:
plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3)) plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3))
...@@ -138,7 +138,7 @@ def _macosx_vers(_cache=[]): ...@@ -138,7 +138,7 @@ def _macosx_vers(_cache=[]):
def _macosx_arch(machine): def _macosx_arch(machine):
return {'PowerPC':'ppc', 'Power_Macintosh':'ppc'}.get(machine,machine) return {'PowerPC':'ppc', 'Power_Macintosh':'ppc'}.get(machine,machine)
def get_platform(): def get_build_platform():
"""Return this platform's string for platform-specific distributions """Return this platform's string for platform-specific distributions
XXX Currently this is the same as ``distutils.util.get_platform()``, but it XXX Currently this is the same as ``distutils.util.get_platform()``, but it
...@@ -160,7 +160,7 @@ def get_platform(): ...@@ -160,7 +160,7 @@ def get_platform():
macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)") macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)") darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
get_platform = get_build_platform # XXX backward compat
def compatible_platforms(provided,required): def compatible_platforms(provided,required):
"""Can code for the `provided` platform run on the `required` platform? """Can code for the `provided` platform run on the `required` platform?
...@@ -171,8 +171,6 @@ def compatible_platforms(provided,required): ...@@ -171,8 +171,6 @@ def compatible_platforms(provided,required):
""" """
if provided is None or required is None or provided==required: if provided is None or required is None or provided==required:
return True # easy case return True # easy case
provided = _get_max_platform(provided)
if provided==required: return True
# Mac OS X special cases # Mac OS X special cases
reqMac = macosVersionString.match(required) reqMac = macosVersionString.match(required)
...@@ -203,6 +201,8 @@ def compatible_platforms(provided,required): ...@@ -203,6 +201,8 @@ def compatible_platforms(provided,required):
provMac.group(3) != reqMac.group(3): provMac.group(3) != reqMac.group(3):
return False return False
# is the required OS major update >= the provided one? # is the required OS major update >= the provided one?
if int(provMac.group(2)) > int(reqMac.group(2)): if int(provMac.group(2)) > int(reqMac.group(2)):
return False return False
...@@ -616,7 +616,7 @@ class WorkingSet(object): ...@@ -616,7 +616,7 @@ class WorkingSet(object):
class Environment(object): class Environment(object):
"""Searchable snapshot of distributions on a search path""" """Searchable snapshot of distributions on a search path"""
def __init__(self,search_path=None,platform=get_platform(),python=PY_MAJOR): def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR):
"""Snapshot distributions available on a search path """Snapshot distributions available on a search path
Any distributions found on `search_path` are added to the environment. Any distributions found on `search_path` are added to the environment.
......
Metadata-Version: 1.0 Metadata-Version: 1.0
Name: setuptools Name: setuptools
Version: 0.7a1dev-r45521 Version: 0.7a1dev-r45536
Summary: Download, build, install, upgrade, and uninstall Python packages -- easily! Summary: Download, build, install, upgrade, and uninstall Python packages -- easily!
Home-page: http://peak.telecommunity.com/DevCenter/setuptools Home-page: http://peak.telecommunity.com/DevCenter/setuptools
Author: Phillip J. Eby Author: Phillip J. Eby
......
...@@ -8,7 +8,7 @@ from setuptools import Command ...@@ -8,7 +8,7 @@ from setuptools import Command
from distutils.dir_util import remove_tree, mkpath from distutils.dir_util import remove_tree, mkpath
from distutils.sysconfig import get_python_version, get_python_lib from distutils.sysconfig import get_python_version, get_python_lib
from distutils import log from distutils import log
from pkg_resources import get_platform, Distribution from pkg_resources import get_build_platform, Distribution
from types import CodeType from types import CodeType
from setuptools.extension import Library from setuptools.extension import Library
...@@ -48,7 +48,7 @@ class bdist_egg(Command): ...@@ -48,7 +48,7 @@ class bdist_egg(Command):
"temporary directory for creating the distribution"), "temporary directory for creating the distribution"),
('plat-name=', 'p', ('plat-name=', 'p',
"platform name to embed in generated filenames " "platform name to embed in generated filenames "
"(default: %s)" % get_platform()), "(default: %s)" % get_build_platform()),
('exclude-source-files', None, ('exclude-source-files', None,
"remove all .py files from the generated egg"), "remove all .py files from the generated egg"),
('keep-temp', 'k', ('keep-temp', 'k',
...@@ -99,7 +99,7 @@ class bdist_egg(Command): ...@@ -99,7 +99,7 @@ class bdist_egg(Command):
self.bdist_dir = os.path.join(bdist_base, 'egg') self.bdist_dir = os.path.join(bdist_base, 'egg')
if self.plat_name is None: if self.plat_name is None:
self.plat_name = get_platform() self.plat_name = get_build_platform()
self.set_undefined_options('bdist',('dist_dir', 'dist_dir')) self.set_undefined_options('bdist',('dist_dir', 'dist_dir'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment