aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-07-21 16:11:34 +0000
committerPJ Eby <distutils-sig@python.org>2005-07-21 16:11:34 +0000
commit1b23ba3c222a3e4d09138bf2e252caa171cdc420 (patch)
treef3993d080f3623ccdea86f0732a6f5709e190592
parentdce75aeae87e88e11ca54d5354e3af8216c39e89 (diff)
downloadexternal_python_setuptools-1b23ba3c222a3e4d09138bf2e252caa171cdc420.tar.gz
external_python_setuptools-1b23ba3c222a3e4d09138bf2e252caa171cdc420.tar.bz2
external_python_setuptools-1b23ba3c222a3e4d09138bf2e252caa171cdc420.zip
Improved backward compatibility of Mac OS platform string changes, thanks
to more help from Kevin Dangoor. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041143
-rwxr-xr-xEasyInstall.txt11
-rwxr-xr-xapi_tests.txt10
-rw-r--r--pkg_resources.py77
3 files changed, 74 insertions, 24 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt
index 73cbf9ce..d48757cc 100755
--- a/EasyInstall.txt
+++ b/EasyInstall.txt
@@ -620,12 +620,11 @@ Known Issues
0.6a1
* Added support for handling MacOS platform information in ``.egg`` filenames,
- based on a contribution by Kevin Dangoor. (NOTE: this may make eggs
- compiled for OS X with older versions of setuptools unusable! If you have
- eggs whose file/directory names end with ``-darwin-*.egg``, you will
- probably need to rename them to ``-macosx-*.egg``, substituting your current
- Mac OS version for the darwin kernel version in the version number. Or, you
- can just delete and reinstall the problematic eggs.)
+ based on a contribution by Kevin Dangoor. You may wish to delete and
+ reinstall any eggs whose filename includes "darwin" and "Power_Macintosh",
+ because the format for this platform information has changed so that minor
+ OS X upgrades (such as 10.4.1 to 10.4.2) do not cause eggs built with a
+ previous OS version to become obsolete.
* Fixed installing extra ``.pyc`` or ``.pyo`` files for scripts with ``.py``
extensions.
diff --git a/api_tests.txt b/api_tests.txt
index e1298ea7..ad5ea819 100755
--- a/api_tests.txt
+++ b/api_tests.txt
@@ -280,3 +280,13 @@ number does not matter::
>>> cp("macosx-9.5-ppc", reqd)
False
+Backwards compatibility for packages made via earlier versions of
+setuptools is provided as well::
+
+ >>> cp("darwin-8.2.0-Power_Macintosh", reqd)
+ True
+ >>> cp("darwin-7.2.0-Power_Macintosh", reqd)
+ True
+ >>> cp("darwin-8.2.0-Power_Macintosh", "macosx-10.3-ppc")
+ False
+
diff --git a/pkg_resources.py b/pkg_resources.py
index f9d6e1ac..b3ce9701 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -92,6 +92,8 @@ def _macosx_vers(_cache=[]):
raise ValueError, "What?!"
return _cache[0]
+def _macosx_arch(machine):
+ return {'PowerPC':'ppc', 'Power_Macintosh':'ppc'}.get(machine,machine)
def get_platform():
"""Return this platform's string for platform-specific distributions
@@ -103,21 +105,19 @@ def get_platform():
try:
version = _macosx_vers()
machine = os.uname()[4].replace(" ", "_")
- machine = {
- 'PowerPC':'ppc', 'Power_Macintosh':'ppc'
- }.get(machine,machine)
return "macosx-%d.%d-%s" % (int(version[0]), int(version[1]),
- machine)
+ _macosx_arch(machine))
except ValueError:
# if someone is running a non-Mac darwin system, this will fall
# through to the default implementation
pass
-
+
from distutils.util import get_platform
return get_platform()
macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
-# XXX darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
+darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
+
@@ -135,33 +135,44 @@ def compatible_platforms(provided,required):
reqMac = macosVersionString.match(required)
if reqMac:
provMac = macosVersionString.match(provided)
-
+
# is this a Mac package?
if not provMac:
- # XXX backward compatibility should go here!
- return False
-
+ # this is backwards compatibility for packages built before
+ # setuptools 0.6. All packages built after this point will
+ # use the new macosx designation.
+ provDarwin = darwinVersionString.match(provided)
+ if provDarwin:
+ dversion = int(provDarwin.group(1))
+ macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2))
+ if dversion == 7 and macosversion >= "10.3" or \
+ dversion == 8 and macosversion >= "10.4":
+
+ #import warnings
+ #warnings.warn("Mac eggs should be rebuilt to "
+ # "use the macosx designation instead of darwin.",
+ # category=DeprecationWarning)
+ return True
+
+ return False # egg isn't macosx or legacy darwin
+
# are they the same major version and machine type?
if provMac.group(1) != reqMac.group(1) or \
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
-
+
return True
- # XXX Linux and other platforms' special cases should go here
+ # XXX Linux and other platforms' special cases should go here
return False
-
-
-
-
-
def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
ns = sys._getframe(1).f_globals
@@ -173,6 +184,25 @@ def run_script(dist_spec, script_name):
run_main = run_script # backward compatibility
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
class IMetadataProvider:
def has_metadata(name):
@@ -203,6 +233,17 @@ class IMetadataProvider:
+
+
+
+
+
+
+
+
+
+
+
class IResourceProvider(IMetadataProvider):
"""An object that provides access to package resources"""