__main__.py is broken
walkerh opened this issue · 2 comments
walkerh commented
__main__.py
imports the module {{cookiecutter.package_name}}.cli
and then attempts to call the module rather than the function inside.
The name "cli" is both the name of a module and the name of a function inside that model.
Instead __main__.py
should do this:
from temp.cli import cli
cli()
Here is a transcript of the problem and a hotfix:
dev$ cookiecutter cookiecutter-conda-python
full_name [Walker Hale]:
email [walker.hale.iv@gmail.com]:
github_username [walkerh]:
repo_name [repository_name]: temp
package_name [temp]:
project_short_description [Short description]:
version [0.1.1-a0]:
dev$ cd temp
temp$ python -m temp
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/hale/Documents/HGSC/dev/repo/third-party/temp/temp/__main__.py", line 3, in <module>
cli()
TypeError: 'module' object is not callable
temp$
temp$ # And now a hotfix...
temp$
temp$ cat <<EOD > temp/__main__.py
> from temp.cli import cli
>
> cli()
> EOD
temp$
temp$ # Test it.
temp$ python -m temp
CLI template
temp$
walkerh commented
Looks like this was fixed in ce1d3cd. See __main__.py
in that commit.
github-actions commented
Hi there, thank you for your contribution!
This issue has been automatically locked because it has not had recent activity after being closed.
Please open a new issue if needed.
Thanks!