Commit 3bf8c4fa authored by PJ Eby's avatar PJ Eby

Backport all known 2.5-compatibility fixes

--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4051935
parent 7e0489e5
......@@ -331,6 +331,10 @@ used to install it. Thus, if you install EasyInstall for both Python 2.3 and
2.4, you can use the ``easy_install-2.3`` or ``easy_install-2.4`` scripts to
install packages for Python 2.3 or 2.4, respectively.
Also, if you're working with Python version 2.4 or higher, you can run Python
with ``-m easy_install`` to run that particular Python version's
``easy_install`` command.
Restricting Downloads with ``--allow-hosts``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -1190,6 +1194,11 @@ displayed MD5 info (broken onto two lines for readability)::
Release Notes/Change History
============================
0.6c3
* You once again use "python -m easy_install" with Python 2.4 and above.
* Python 2.5 compatibility fixes added.
0.6c2
* Windows script wrappers now support quoted arguments and arguments
containing spaces. (Patch contributed by Jim Fulton.)
......
......@@ -274,13 +274,13 @@ exception instance for each unloadable plugin::
>>> ws.add(foo12) # this will conflict with Foo 1.4
>>> ws.find_plugins(plugins)
([JustATest 0.99, Foo 1.2 (f12)], {Foo 1.4 (f14): <...VersionConflict...>})
([JustATest 0.99, Foo 1.2 (f12)], {Foo 1.4 (f14): VersionConflict(...)})
But if you disallow fallbacks, the failed plugin will be skipped instead of
trying older versions::
>>> ws.find_plugins(plugins, fallback=False)
([JustATest 0.99], {Foo 1.4 (f14): <...VersionConflict...>})
([JustATest 0.99], {Foo 1.4 (f14): VersionConflict(...)})
......
#!python
"""\
This script/module exists for backward compatibility only! It will go away
entirely in 0.7. Please start using the 'easy_install' script or .exe instead
of using 'python -m easy_install' or running 'easy_install.py' directly.
"""
"""Run the EasyInstall command"""
if __name__ == '__main__':
import sys
print >>sys.stderr, \
"Please use the 'easy_install' script or executable instead."
print >>sys.stderr, \
"(i.e., don't include the '.py' extension and don't use 'python -m')"
sys.exit(2)
from setuptools.command.easy_install import main
main()
......@@ -58,7 +58,7 @@ __all__ = [
# Exceptions
'ResolutionError','VersionConflict','DistributionNotFound','UnknownExtra',
'ExtractionError',
# Parsing functions and string utilities
'parse_requirements', 'parse_version', 'safe_name', 'safe_version',
'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections',
......@@ -82,6 +82,7 @@ __all__ = [
]
class ResolutionError(Exception):
"""Abstract base for dependency resolution errors"""
def __repr__(self): return self.__class__.__name__+repr(self.args)
class VersionConflict(ResolutionError):
"""An already-installed version conflicts with the requested version"""
......@@ -91,7 +92,6 @@ class DistributionNotFound(ResolutionError):
class UnknownExtra(ResolutionError):
"""Distribution doesn't have an "extra feature" of the given name"""
_provider_factories = {}
PY_MAJOR = sys.version[:3]
EGG_DIST = 3
......@@ -823,7 +823,7 @@ class ResourceManager:
old_exc = sys.exc_info()[1]
cache_path = self.extraction_path or get_default_cache()
err = ExtractionError("""Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
......@@ -878,7 +878,7 @@ variable to point to an accessible directory.
ensure_directory(target_path)
except:
self.extraction_error()
self.cached_files[target_path] = 1
return target_path
......@@ -1264,11 +1264,11 @@ class ZipProvider(EggProvider):
try:
rename(tmpnam, real_path)
except os.error:
except os.error:
if os.path.isfile(real_path):
stat = os.stat(real_path)
if stat.st_size==size and stat.st_mtime==timestamp:
# size and stamp match, somebody did it just ahead of
# us, so we're done
......
......@@ -23,8 +23,6 @@ VERSION = "0.6c3"
from setuptools import setup, find_packages
import sys
scripts = []
if sys.platform != "win32":
scripts = ["easy_install.py"] # for backward compatibility only
setup(
name="setuptools",
......@@ -38,13 +36,12 @@ setup(
keywords = "CPAN PyPI distutils eggs package management",
url = "http://peak.telecommunity.com/DevCenter/setuptools",
test_suite = 'setuptools.tests',
packages = find_packages(),
package_data = {'setuptools':['*.exe']},
py_modules = ['pkg_resources', 'easy_install', 'site'],
zip_safe = False, # We want 'python -m easy_install' to work, for now :(
zip_safe = (sys.version>="2.5"), # <2.5 needs unzipped for -m to work
entry_points = {
......@@ -80,12 +77,15 @@ setup(
"dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
],
"console_scripts": [
"easy_install = setuptools.command.easy_install:main",
"easy_install-%s = setuptools.command.easy_install:main"
% sys.version[:3]
],
"setuptools.file_finders":
["svn_cvs = setuptools.command.sdist:_default_revctrl"]
},
......
......@@ -5,6 +5,10 @@ __all__ = [
'register',
]
import sys
if sys.version>='2.5':
# In Python 2.5 and above, distutils includes its own upload command
__all__.remove('upload')
from distutils.command.bdist import bdist
......@@ -12,4 +16,4 @@ if 'egg' not in bdist.format_commands:
bdist.format_command['egg'] = ('bdist_egg', "Python .egg file")
bdist.format_commands.append('egg')
del bdist
del bdist, sys
......@@ -1588,6 +1588,7 @@ usage: %(script)s [options] requirement_or_url ...
with_ei_usage(lambda:
setup(
script_args = ['-q','easy_install', '-v']+argv,
script_name = sys.argv[0] or 'easy_install',
distclass=DistributionWithoutHelpCommands, **kw
)
)
......@@ -1596,4 +1597,3 @@ usage: %(script)s [options] requirement_or_url ...
__all__ = ['Distribution', 'Feature']
__all__ = ['Distribution']
from distutils.core import Distribution as _Distribution
from setuptools.depends import Require
......@@ -207,7 +207,7 @@ class Distribution(_Distribution):
have_package_data = hasattr(self, "package_data")
if not have_package_data:
self.package_data = {}
self.requires = [] # XXX
self.require_features = []
self.features = {}
self.dist_files = []
self.patch_missing_pkg_info(attrs)
......@@ -676,10 +676,10 @@ class Feature:
based on 'availabile', 'standard', and whether any other feature
requires it. The default setting is 'True'.
'requires' -- a string or sequence of strings naming features that should
also be included if this feature is included. Defaults to empty list.
May also contain 'Require' objects that should be added/removed from
the distribution.
'require_features' -- a string or sequence of strings naming features
that should also be included if this feature is included. Defaults to
empty list. May also contain 'Require' objects that should be
added/removed from the distribution.
'remove' -- a string or list of strings naming packages to be removed
from the distribution if this feature is *not* included. If the
......@@ -704,34 +704,34 @@ class Feature:
Aside from the methods, the only feature attributes that distributions look
at are 'description' and 'optional'.
"""
def __init__(self, description, standard=False, available=True,
optional=True, requires=(), remove=(), **extras
optional=True, require_features=(), remove=(), **extras
):
self.description = description
self.standard = standard
self.available = available
self.optional = optional
if isinstance(requires,(str,Require)):
requires = requires,
if isinstance(require_features,(str,Require)):
require_features = require_features,
self.requires = [r for r in requires if isinstance(r,str)]
er = [r for r in requires if not isinstance(r,str)]
if er: extras['requires'] = er
self.require_features = [
r for r in require_features if isinstance(r,str)
]
er = [r for r in require_features if not isinstance(r,str)]
if er: extras['require_features'] = er
if isinstance(remove,str):
remove = remove,
self.remove = remove
self.extras = extras
if not remove and not requires and not extras:
if not remove and not require_features and not extras:
raise DistutilsSetupError(
"Feature %s: must define 'requires', 'remove', or at least one"
"Feature %s: must define 'require_features', 'remove', or at least one"
" of 'packages', 'py_modules', etc."
)
def include_by_default(self):
"""Should this feature be included by default?"""
return self.available and self.standard
......@@ -754,7 +754,7 @@ class Feature:
dist.include(**self.extras)
for f in self.requires:
for f in self.require_features:
dist.include_feature(f)
......
......@@ -255,7 +255,7 @@ class FeatureTests(TestCase):
self.req = Require('Distutils','1.0.3','distutils')
self.dist = makeSetup(
features={
'foo': Feature("foo",standard=True,requires=['baz',self.req]),
'foo': Feature("foo",standard=True,require_features=['baz',self.req]),
'bar': Feature("bar", standard=True, packages=['pkg.bar'],
py_modules=['bar_et'], remove=['bar.ext'],
),
......@@ -281,7 +281,7 @@ class FeatureTests(TestCase):
self.failUnless(
Feature("test",standard=True,remove='x').include_by_default()
)
# Feature must have either kwargs, removes, or requires
# Feature must have either kwargs, removes, or require_features
self.assertRaises(DistutilsSetupError, Feature, "test")
def testAvailability(self):
......@@ -320,7 +320,7 @@ class FeatureTests(TestCase):
self.failUnless('scripts/baz_it' in dist.scripts)
self.failUnless(('libfoo','foo/foofoo.c') in dist.libraries)
self.assertEqual(dist.ext_modules,[])
self.assertEqual(dist.requires, [self.req])
self.assertEqual(dist.require_features, [self.req])
# If we ask for bar, it should fail because we explicitly disabled
# it on the command line
......
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