From 9848b7fd5c1e4941f42de294278ee5cb7fc3b59b Mon Sep 17 00:00:00 2001 From: Sean Monahan <smonahan@alnylam.com> Date: Thu, 29 Mar 2018 13:54:37 -0400 Subject: [PATCH 1/2] moved main() into __main__.py to keep __init__.py minimal --- sample/__init__.py | 4 ---- sample/__main__.py | 8 ++++++++ setup.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 sample/__main__.py diff --git a/sample/__init__.py b/sample/__init__.py index db836cee..e69de29b 100644 --- a/sample/__init__.py +++ b/sample/__init__.py @@ -1,4 +0,0 @@ - -def main(): - """Entry point for the application script""" - print("Call your main application code here") diff --git a/sample/__main__.py b/sample/__main__.py new file mode 100644 index 00000000..81368abb --- /dev/null +++ b/sample/__main__.py @@ -0,0 +1,8 @@ + +def main(): + """Entry point for the application script""" + print("Call your main application code here") + +if __name__ == "__main__": + main() + diff --git a/setup.py b/setup.py index 27227e0b..c3625f20 100644 --- a/setup.py +++ b/setup.py @@ -162,7 +162,7 @@ # executes the function `main` from this package when invoked: entry_points={ # Optional 'console_scripts': [ - 'sample=sample:main', + 'sample=sample.__main__:main', ], }, From 7b4b0cabe42ebc71c2a510634600484c3af4c994 Mon Sep 17 00:00:00 2001 From: Sean Monahan <smonahan@alnylam.com> Date: Thu, 29 Mar 2018 14:10:30 -0400 Subject: [PATCH 2/2] fixed newlines breaking flake8 tests --- sample/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/__main__.py b/sample/__main__.py index 81368abb..4d498e4e 100644 --- a/sample/__main__.py +++ b/sample/__main__.py @@ -3,6 +3,6 @@ def main(): """Entry point for the application script""" print("Call your main application code here") + if __name__ == "__main__": main() -