diff options
author | PJ Eby <distutils-sig@python.org> | 2006-04-18 16:16:33 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2006-04-18 16:16:33 +0000 |
commit | fe16ffbec3ca87fbfb0071c5a0d80e6c2fc9efee (patch) | |
tree | f5109c2a3e336778d81956a58f3c80e6f5d7ea1e | |
parent | 150889dedfa7345ef5681224415d313cc01fa101 (diff) | |
download | external_python_setuptools-fe16ffbec3ca87fbfb0071c5a0d80e6c2fc9efee.tar.gz external_python_setuptools-fe16ffbec3ca87fbfb0071c5a0d80e6c2fc9efee.tar.bz2 external_python_setuptools-fe16ffbec3ca87fbfb0071c5a0d80e6c2fc9efee.zip |
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.
(Backport from 0.7 trunk, rev 45536)
--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4045538
-rw-r--r-- | pkg_resources.py | 14 | ||||
-rwxr-xr-x | pkg_resources.txt | 19 | ||||
-rw-r--r-- | setuptools/command/bdist_egg.py | 6 |
3 files changed, 27 insertions, 12 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index 01c784e4..62b6ab1a 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -18,7 +18,7 @@ from sets import ImmutableSet from os import utime, rename, unlink # capture these to bypass sandboxing from os import open as os_open -def _get_max_platform(plat): +def get_supported_platform(): """Return this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version @@ -31,7 +31,7 @@ def _get_max_platform(plat): If this condition occurs for any other platform with a version in its 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": try: plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3)) @@ -136,7 +136,7 @@ def _macosx_vers(_cache=[]): def _macosx_arch(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 XXX Currently this is the same as ``distutils.util.get_platform()``, but it @@ -158,7 +158,7 @@ def get_platform(): macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)") darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)") - +get_platform = get_build_platform # XXX backward compat @@ -171,8 +171,6 @@ def compatible_platforms(provided,required): """ if provided is None or required is None or provided==required: return True # easy case - provided = _get_max_platform(provided) - if provided==required: return True # Mac OS X special cases reqMac = macosVersionString.match(required) @@ -203,6 +201,8 @@ def compatible_platforms(provided,required): provMac.group(3) != reqMac.group(3): return False + + # is the required OS major update >= the provided one? if int(provMac.group(2)) > int(reqMac.group(2)): return False @@ -616,7 +616,7 @@ class WorkingSet(object): class Environment(object): """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 Any distributions found on `search_path` are added to the environment. diff --git a/pkg_resources.txt b/pkg_resources.txt index a7cbd42a..fff4fa99 100755 --- a/pkg_resources.txt +++ b/pkg_resources.txt @@ -441,7 +441,7 @@ that are present and potentially importable on the current platform. ``Environment`` objects are used by ``pkg_resources`` to index available distributions during dependency resolution. -``Environment(search_path=None, platform=get_platform(), python=PY_MAJOR)`` +``Environment(search_path=None, platform=get_supported_platform(), python=PY_MAJOR)`` Create an environment snapshot by scanning `search_path` for distributions compatible with `platform` and `python`. `search_path` should be a sequence of strings such as might be used on ``sys.path``. If a @@ -1590,11 +1590,21 @@ Parsing Utilities Platform Utilities ------------------ -``get_platform()`` +``get_build_platform()`` Return this platform's identifier string. For Windows, the return value is ``"win32"``, and for Mac OS X it is a string of the form ``"macosx-10.4-ppc"``. All other platforms return the same uname-based string that the ``distutils.util.get_platform()`` function returns. + This string is the minimum platform version required by distributions built + on the local machine. (Backward compatibility note: setuptools versions + prior to 0.6b1 called this function ``get_platform()``, and the function is + still available under that name for backward compatibility reasons.) + +``get_supported_platform()`` (New in 0.6b1) + This is the similar to ``get_build_platform()``, but is the maximum + platform version that the local machine supports. You will usually want + to use this value as the ``provided`` argument to the + ``compatible_platforms()`` function. ``compatible_platforms(provided, required)`` Return true if a distribution built on the `provided` platform may be used @@ -1652,6 +1662,11 @@ File/Path Utilities Release Notes/Change History ---------------------------- +0.6b1 + * 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. + 0.6a11 * Added ``ExtractionError`` and ``ResourceManager.extraction_error()`` so that cache permission problems get a more user-friendly explanation of the diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index d571ac80..74f2d426 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -8,7 +8,7 @@ from setuptools import Command from distutils.dir_util import remove_tree, mkpath from distutils.sysconfig import get_python_version, get_python_lib from distutils import log -from pkg_resources import get_platform, Distribution +from pkg_resources import get_build_platform, Distribution from types import CodeType from setuptools.extension import Library @@ -48,7 +48,7 @@ class bdist_egg(Command): "temporary directory for creating the distribution"), ('plat-name=', 'p', "platform name to embed in generated filenames " - "(default: %s)" % get_platform()), + "(default: %s)" % get_build_platform()), ('exclude-source-files', None, "remove all .py files from the generated egg"), ('keep-temp', 'k', @@ -99,7 +99,7 @@ class bdist_egg(Command): self.bdist_dir = os.path.join(bdist_base, 'egg') 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')) |