summaryrefslogtreecommitdiff
path: root/pkg_resources.py
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 /pkg_resources.py
parentdce75aeae87e88e11ca54d5354e3af8216c39e89 (diff)
downloadpython-setuptools-git-1b23ba3c222a3e4d09138bf2e252caa171cdc420.tar.gz
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
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py77
1 files changed, 59 insertions, 18 deletions
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"""