aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg_resources.py30
-rwxr-xr-xpkg_resources.txt6
2 files changed, 21 insertions, 15 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index d2398cad..07b5675e 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -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
)
@@ -1953,19 +1966,6 @@ class Distribution(object):
-
-
-
-
-
-
-
-
-
-
-
-
-
def parse_requirements(strs):
"""Yield ``Requirement`` objects for each specification in `strs`
diff --git a/pkg_resources.txt b/pkg_resources.txt
index e0bca237..c58f63f8 100755
--- a/pkg_resources.txt
+++ b/pkg_resources.txt
@@ -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.