I've been trying to package my project with setup.py, but I ran into a snag.
My file structure is as follows:
root/
mypackage/
__init__.py
mysubmodule1/
__init__.py
mysubmodule2/
__init__.py
I'm using the following configuration in my setup.py,
from setuptools import setup, find_packages
# To use a consistent encoding
from os import path
import glob
here = path.abspath(path.dirname(__file__))
print(find_packages(exclude=['docs', 'tests*']))
setup(
name='mypackage',
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
install_requires=[...],
scripts=[...],
)
I build the package with python setup.py install inside a virtualenv, the debug line I printed showed that find_packages located all my pacakges.
['mypackage', 'mypackage.submodule1', 'mypackage.submodule2']
When I import my package, I attempted to import mypackage.submodule1.class, but this threw a module not found exception. I checked that all my modules are in the output egg in the virtualenv site-packages, and that I can import my root package.
The output of the dir(mypackage) is as follows:
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mypackage
>>> dir(mypackage)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__']
Am I missing something? All the opensource projects I referenced follow this pattern. Thanks