diff options
author | PJ Eby <distutils-sig@python.org> | 2005-11-18 02:07:30 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-11-18 02:07:30 +0000 |
commit | 9a787c343b5f58f62441f89163c7507f91a98ff9 (patch) | |
tree | 4a480555b4f273f990fae6cf7fc5e6f19738ee14 | |
parent | fd21ab7f9ab4b462d6ffb81b77b699c5eef6d28c (diff) | |
download | external_python_setuptools-9a787c343b5f58f62441f89163c7507f91a98ff9.tar.gz external_python_setuptools-9a787c343b5f58f62441f89163c7507f91a98ff9.tar.bz2 external_python_setuptools-9a787c343b5f58f62441f89163c7507f91a98ff9.zip |
Don't raise an error when an invalid (unfinished) distribution is found
unless absolutely necessary. Warn about skipping invalid/unfinished eggs
when building an Environment.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041469
-rw-r--r-- | pkg_resources.py | 44 | ||||
-rwxr-xr-x | pkg_resources.txt | 7 |
2 files changed, 28 insertions, 23 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index eb4612a5..4cf262b7 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -605,7 +605,7 @@ class Environment(object): def add(self,dist): """Add `dist` if we ``can_add()`` it and it isn't already added""" - if self.can_add(dist): + if self.can_add(dist) and dist.has_version(): dists = self._distmap.setdefault(dist.key,[]) if dist not in dists: dists.append(dist) @@ -1940,31 +1940,31 @@ class Distribution(object): fn = getattr(sys.modules[modname], '__file__', None) if fn and fn.startswith(self.location): continue - - level = 1 - g = globals() - try: - # find the first stack frame that is *not* code in - # the pkg_resources module, to use for the warning - while sys._getframe(level).f_globals is g: - level += 1 - except ValueError: - pass - - from warnings import warn - warn( + issue_warning( "Module %s was already imported from %s, but %s is being added" " to sys.path" % (modname, fn, self.location), - stacklevel = level+1 ) + def has_version(self): + try: + self.version + except ValueError: + issue_warning("Unbuilt egg for "+repr(self)) + return False + return True - - - - - - +def issue_warning(*args,**kw): + level = 1 + g = globals() + try: + # find the first stack frame that is *not* code in + # the pkg_resources module, to use for the warning + while sys._getframe(level).f_globals is g: + level += 1 + except ValueError: + pass + from warnings import warn + warn(stacklevel = level+1, *args, **kw) def parse_requirements(strs): """Yield ``Requirement`` objects for each specification in `strs` @@ -2076,7 +2076,7 @@ class Requirement: def __contains__(self,item): if isinstance(item,Distribution): if item.key <> self.key: return False - item = item.parsed_version + if self.index: item = item.parsed_version # only get if we need it elif isinstance(item,basestring): item = parse_version(item) last = None diff --git a/pkg_resources.txt b/pkg_resources.txt index 3018dd8e..8185c793 100755 --- a/pkg_resources.txt +++ b/pkg_resources.txt @@ -1348,7 +1348,7 @@ Parsing Utilities The algorithm assumes that strings like "-" and any alpha string that alphabetically follows "final" represents a "patch level". So, "2.4-1" is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is - considered newer than "2.4-1", whic in turn is newer than "2.4". + considered newer than "2.4-1", which in turn is newer than "2.4". Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that come before "final" alphabetically) are assumed to be pre-release versions, @@ -1488,6 +1488,11 @@ File/Path Utilities Release Notes/Change History ---------------------------- +0.6a9 + * Don't raise an error when an invalid (unfinished) distribution is found + unless absolutely necessary. Warn about skipping invalid/unfinished eggs + when building an Environment. + 0.6a8 * Fixed a problem with ``WorkingSet.resolve()`` that prevented version conflicts from being detected at runtime. |