summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-11-04 01:53:25 +0000
committerPJ Eby <distutils-sig@python.org>2005-11-04 01:53:25 +0000
commitd948d4c659d8fd4920cf1837aba140615e2a8fe5 (patch)
tree5504ff478e0b7ae855f00e9fca9f945cb6597716 /pkg_resources.py
parent1f065479e3f02f168be10f0aad017bddfaa3580d (diff)
downloadpython-setuptools-git-d948d4c659d8fd4920cf1837aba140615e2a8fe5.tar.gz
* 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
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py30
1 files changed, 15 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`