diff options
author | PJ Eby <distutils-sig@python.org> | 2005-11-04 01:53:25 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-11-04 01:53:25 +0000 |
commit | d948d4c659d8fd4920cf1837aba140615e2a8fe5 (patch) | |
tree | 5504ff478e0b7ae855f00e9fca9f945cb6597716 | |
parent | 1f065479e3f02f168be10f0aad017bddfaa3580d (diff) | |
download | external_python_setuptools-d948d4c659d8fd4920cf1837aba140615e2a8fe5.tar.gz external_python_setuptools-d948d4c659d8fd4920cf1837aba140615e2a8fe5.tar.bz2 external_python_setuptools-d948d4c659d8fd4920cf1837aba140615e2a8fe5.zip |
* 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
-rw-r--r-- | pkg_resources.py | 30 | ||||
-rwxr-xr-x | pkg_resources.txt | 6 |
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. |