I am trying to run a packaged cli, which does dynamic imports. When I run the code through the main cli script it works as expected. However after I package the code up using setup.py sdist
and then install the dist tar with pip. The cli itself gives an import error ImportError: No module named
. All of the modules are in the same folder as the cli.py
file.
This is how I have created my main called cli.py
def main():
args = docopt(__doc__, version="1.0")
argv = [args['<command>']] + args['<args>']
module = importlib.import_module(args['<command>'])
print(docopt(module.__doc__, argv=argv))
if __name__ == '__main__':
main()
And my setup.py looks like this
from setuptools import setup
setup(
name='testing-cli',
version='0.0.1',
packages=['testing']
entry_points = {
'console_scripts': ['testing-cli = testing.cli:main'],
}
)
Any ideas as to why when packaged I get an import error when it is packaged but when running like ./cli.py <arg>
it imports fine?