Skip to content

Commit

Permalink
Add working command_name_for_function_in__main__ for `entry_points[…
Browse files Browse the repository at this point in the history
…'console_scripts']`
  • Loading branch information
shailshouryya committed Feb 20, 2023
1 parent 5811710 commit a07c7f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@

entry_points={ # Optional
'console_scripts': [
'command_name=test_project_python:function_name', # compare the output of `command_name` versus `python3 -m test_project_python`
'command_name=test_project_python:function_name', # compare the output of `command_name` versus `python3 -m test_project_python`
'command_name_for_function_in__main__=test_project_python.__main__:function_in__main__', # compare the output of `command_name_for_function_in__main__` versus `python3 -m test_project_python`
],
},

Expand Down
3 changes: 3 additions & 0 deletions python/test_project_python/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
print('Entered test_project_python.__main__ :)')

def function_in__main__():
print('Ran test_project_python.__main__.function_in__main__')

if __name__ == '__main__':
print('__name__ == "__main__" is True for test_project_python.__main__')
function_in__main__()

0 comments on commit a07c7f2

Please sign in to comment.