Commit d948d4c6 authored by PJ Eby's avatar PJ Eby

* Improved runtime conflict warning message to identify a line in the user's

  program, rather than flagging the ``warn()`` call in ``pkg_resources``.

* Avoid giving runtime conflict warnings for namespace packages, even if they
  were declared by a different package than the one currently being activated.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041391
parent 1f065479
......@@ -1932,17 +1932,30 @@ class Distribution(object):
nsp = dict.fromkeys(self._get_metadata('namespace_packages.txt'))
for modname in self._get_metadata('top_level.txt'):
if modname not in sys.modules or modname in nsp:
if (modname not in sys.modules or modname in nsp
or modname in _namespace_packages
):
continue
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(
"Module %s was already imported from %s, but %s is being added"
" to sys.path" % (modname, fn, self.location)
" to sys.path" % (modname, fn, self.location),
stacklevel = level+1
)
......@@ -1951,19 +1964,6 @@ class Distribution(object):
def parse_requirements(strs):
......
......@@ -1492,6 +1492,12 @@ Release Notes/Change History
* Fixed a problem with ``WorkingSet.resolve()`` that prevented version
conflicts from being detected at runtime.
* Improved runtime conflict warning message to identify a line in the user's
program, rather than flagging the ``warn()`` call in ``pkg_resources``.
* Avoid giving runtime conflict warnings for namespace packages, even if they
were declared by a different package than the one currently being activated.
0.6a6
* Activated distributions are now inserted in ``sys.path`` (and the working
set) just before the directory that contains them, instead of at the end.
......
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