I have a Python package called cmdline. I use setuptools to define a console entry point. I would like to put this entry point inside a cli submodule, but I get an error when I try to run the installed script.
My project layout looks like this.
setup.py
cmdline/
__init__.py
cli/
__init__.py
main.py
The setup.py looks like this.
from setuptools import setup
setup(
name='cmdline',
version='1.0.0',
packages=['cmdline'],
url='',
license='',
author='W.P. McNeill',
author_email='',
description='',
entry_points={
'console_scripts': ['cmdline=cmdline.cli.main:main'],
}
)
The main.py file looks like this.
def main():
print("Hello, world")
if __name__ == "__main__":
main()
Both __init__.py files are empty.
If I install this with python setup.py install and then try to run the console script, I get an error.
> cmdline
Traceback (most recent call last):
File "//anaconda/envs/cmdline/bin/cmdline", line 9, in <module>
load_entry_point('cmdline==1.0.0', 'console_scripts', 'cmdline')()
File "build/bdist.macosx-10.5-x86_64/egg/pkg_resources/__init__.py", line 542, in load_entry_point
File "build/bdist.macosx-10.5-x86_64/egg/pkg_resources/__init__.py", line 2569, in load_entry_point
File "build/bdist.macosx-10.5-x86_64/egg/pkg_resources/__init__.py", line 2229, in load
File "build/bdist.macosx-10.5-x86_64/egg/pkg_resources/__init__.py", line 2235, in resolve
ImportError: No module named cli.main
If, however, I install it via a softlink with python setup.py develop it works.
> cmdline
Hello, world
It also works if I don't use a cli submodule and just have main.py at the top level of the project.
How can I make the submodule configuration work?