The docs for the (awesome) Click package suggest a few reasons to use entry points instead of scripts, including
- cross-platform compatibility and
- avoiding having the interpreter assign
__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.
The docs for the (awesome) Click package suggest a few reasons to use entry points instead of scripts, including
- cross-platform compatibility and
- avoiding having the interpreter assign
__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).
python console scripts + venv
Using a Python Package with 'console_scripts'
Packaging console scripts with interpreter options - Packaging - Discussions on Python.org
Should console_scripts entry points exclude the scripts directory from sys.path? - Packaging - Discussions on Python.org
hi
So there are a lot of tools that are practically python scripts. Which is great.
You know, all of those "console_scripts" or "scripts" that you see in the setup.
But the thing is, that they don't use the amazing things called virtual environment out of the box. All of their requirements are just installed in the same default environment.
Now usually I just create a virtual environment and manually add a bash script that runs the tool in its own venv. No collisions that way.
But I do it manually. Now before I automate it, I wanted to ask. What do you do? How do you solve this problem?