I am trying to create an installation package for a Python project with unit tests enabled. My project layout is as follows:
setup.py src/ disttest/ __init__.py core.py tests/ disttest/ __init__.py testcore.py
My setup.py
looks like this:
from distutils.core import setup import setuptools setup(name='disttest', version='0.1', package_dir={'': 'src'}, packages=setuptools.find_packages('src'), test_suite='nose.collector', tests_require=['Nose'], )
The file tests/disttest/testcore.py
contains the line from disttest.core import DistTestCore
.
Running setup.py test
now gives ImportError: No module named core
.
After setup.py install
, python -c "from disttest.core import DistTestCore"
works fine. It also works if I put import core
in src/disttest/__init__.py
, but I really don't want to support it, and it only seems necessary for the tests.
Why? And what is the correct way to fix it?
source share