Commit 1b23ba3c authored by PJ Eby's avatar PJ Eby

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
parent dce75aea
......@@ -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.
......
......@@ -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
......@@ -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
......@@ -172,6 +183,25 @@ def run_script(dist_spec, script_name):
run_main = run_script # backward compatibility
class IMetadataProvider:
......@@ -203,6 +233,17 @@ class IMetadataProvider:
class IResourceProvider(IMetadataProvider):
"""An object that provides access to package resources"""
......
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