There are basically two ways to install Python console scripts to my path by setup.py
:
setup(
...
entry_points = {
\'console_scr
One more difference is that when using console_scripts, my module's init file was run. When just using scripts, the module init was not run, only the script was run.
The setup tools entry point approach (#1) also has the benefit that on windows an .exe will be created that can be double clicked and invoked like a regular windows program. This is in addition to having a script placed in the bin path on posix-like systems.
The docs for the (awesome) Click package suggest a few reasons to use entry points instead of scripts, including
__name__
to __main__
, which could cause code to be imported twice (if another module imports your script)Click is a nice way to implement functions for use as entry_points
, btw.
One key difference between these two ways of creating command line executables is that with the setuptools
approach (your first example), you have to call a function inside of the script -- in your case this is the func
inside of your module
. However, in the distutils
approach (your second example) you call the script directly (which allows being listed with or without an extension).