I am preparing to deploy a Python package with the following layout:
MyPackage/
setup.py
MyPackage/
__init__.py
__main__.py
lib/
__init__.py
utils.py
db/
__init__.py
db1.py
db2.py
tasks/
__init__.py
something.py
The setup.py contains:
setup(name = MyPackage,
...
packages = find_packages(),
include_package_data = True,
entry_points = {"console_scripts" : [
"do_something = MyPackage.__main__:main"
]})
__main__.py contains:
import tasks.something as something
something.my_function()
something module contains:
import db.db1 as db1
import db.db2 as db2
def my_function():
db1.this_func(...)
db2.that_func(...)
db1 contains:
import sqlalchemy
import lib.utils as utils
def this_func(...):
sqlalchemy.create_engine(...)
and db2 contains:
import sqlalchemy
import lib.utils as utils
def that_func(...):
sqlalchemy.create_engine(...)
When run by executing from the installed site-packages directory, __main__.py completes without issue. If I perform import MyPackage.tasks.something as something in an interactive session, the module also imports with issue. When I run the console_scripts script do_something, however, I receive ModuleNotFound errors for tasks.
What is causing my console script to fail to locate the subpackages?
Thanks in advance!