gjhiggins/rdflib — Issue #100: Spurious warnings re module test (patch)
Author: gjhiggins
Created: 2011-10-19 01:20:54+00:00
State: open

Originally filed by j...@pobox.com on 2010-01-10T00:26:29

rdflib's setup.py uses setuptools.find_packages, which finds module test in
addition to modules rdflib and rdflib_tools. As a result, the egg info
installed by setuptools lists module test -- e.g. on my Ubuntu karmic
system:

$ cat /usr/lib/pymodules/python2.6/rdflib-2.4.0.egg-info/top_level.txt
test
rdflib
rdflib_tools

For some reason I haven't investigated, module test doesn't actually appear
to get installed. That's a good thing, because Python itself comes with a
module named "test".

However, the presence of "test" in top_level.txt causes spurious warnings
when working on any other project on the same system that both 1. imports
pkg_resources (which may happen indirectly, for example by importing a
setuptools "namespace package" such as zope.interface) and 2. has a module
named "test" -- for example, a file named test.py that runs that project's
tests.

The solution would be to stop using find_packages and just list all of the
packages in rdflib explicitly (rdflib has exactly two packages, after all -
- hardly a great maintenance burden):

sed -i -e 's/find_packages()/["rdflib", "rdflib_tools"]/' setup.py

What steps will reproduce the problem?

$ cat <<"EOF" > fail.sh
sudo apt-get install python-rdflib
dir=$(mktemp -d)
echo "$dir"
cd "$dir"
touch test.py
python -c "import test; import rdflib"
EOF
$ sh fail.sh

What is the expected output? What do you see instead?

Expect: No warning

Got:
...
/usr/lib/python2.6/dist-packages/zope/__init__.py:19: UserWarning: Module
test was already imported from test.py, but /usr/lib/pymodules/python2.6 is
being added to sys.path
import pkg_resources

What version of the product are you using? On what operating system?

python-rdflib 2.4.0-5ubuntu1 Ubuntu 9.10 (karmic)