#1 Merged
  1. Ralph Bean

This will stop pkg_resources from emitting unsettling warnings like this one:

/usr/lib/python2.6/site-packages/fedmsg/meta/init.py:94: UserWarning: Module backports was already imported from /usr/lib64/python2.6/site-packages/backports/init.pyc, but /usr/lib/python2.6/site-packages is being added to sys.path

Comments (6)

  1. Ralph Bean author

    Some more information:

    How can I trigger the warning from pkg_resources?

    I have to import just the backports module first, and then import pkg_resources afterwards:

    $ python
    Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import backports
    >>> import pkg_resources
    __main__:1: UserWarning: Module backports was already imported from /usr/lib64/python2.6/site-packages/backports/__init__.pyc, but /usr/lib/python2.6/site-packages is being added to sys.path

    Might this depend on lib vs lib64 found on some Linux machines?

    It very well might. :)

    The code that emits the warning is somewhere around here: https://bitbucket.org/pypa/setuptools/src/01ec41e9b983dd7d1fdb81b3d07d7b43217fba3e/pkg_resources.py?at=default#cl-2530

    Notice that it is checking for the namespace_packages.txt file in the egg-info. As far as I can tell, that file doesn't get created unless you specify namespace_packages=[...].

  2. Brandon Rhodes repo owner

    Thank you for noting this omission! In moving away from pyron I apparently neglected this crucial declaration.

  3. Brandon Rhodes repo owner

    @peterjc, I think that is the commit I just accepted into this project by accepting this pull request? :)

  4. Robert Collins

    Huh, If I'd run across this earlier I would have suggested not using the pkg_resources/setuptools namespace stuff at all - its very fragile in development and the native namespace implementation from importlib is /much better/ - and efforts are underway to backport that as importlib2. So in the interim using the 'stub package with init only' approach (which you appear to have used) is about 1000% saner.