From d2ad345ff36f12f4d43bbc8beb8365db319f8a5c Mon Sep 17 00:00:00 2001 From: slow-but-steady Date: Mon, 20 Feb 2023 14:29:32 -0800 Subject: [PATCH] Add `print` statement to the top of `test_project_python.__init__` module - simplifies understanding the differences between the following commands: - `command_name` - `command_name_for_function_in__main__` - `python3 -m test_project_python` --- python/test_project_python/__init__.py | 2 ++ python/test_project_python/__main__.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/python/test_project_python/__init__.py b/python/test_project_python/__init__.py index 1580db3..342e732 100644 --- a/python/test_project_python/__init__.py +++ b/python/test_project_python/__init__.py @@ -1,3 +1,5 @@ +print('Entered test_project_python.__init__ :)') + def function_name(): print('Ran test_project_python.__init__.function_name') return True diff --git a/python/test_project_python/__main__.py b/python/test_project_python/__main__.py index d68c18c..172b7c9 100644 --- a/python/test_project_python/__main__.py +++ b/python/test_project_python/__main__.py @@ -2,6 +2,18 @@ def function_in__main__(): print('Ran test_project_python.__main__.function_in__main__') + print(''' + To better understand how commands from the 'console_scripts' key inside + the entry_points dictionary in setup.py works, run and compare + command_name + command_name_for_function_in__main__ + python3 -m test_project_python # Linux/macOS + python -m test_project_python # Windows + custom_py -m test_project_python # if you use a custom alias for python command + This assumes you've already installed the package with: + pip install test_project_python # installs from PyPI + pip install . # installs local version (you need to clone this repo and then run this from the test_project/python directory) + ''') if __name__ == '__main__': print('__name__ == "__main__" is True for test_project_python.__main__')