On Sun, Feb 20, 2022 at 09:56:18AM +0100, Eliot Lear wrote:
Hi everyone,
I'm sure there's a clear answer, probably written some place obvious, but I wonder if there is a reason why certain functions are not linked to console_scripts. In particular I would think this would be good for json.tool (though I might call it something else, like pyjson_pp). Same with venv. I'm sure I'm missing something obvious.
Hi Eliot, What do you mean by "linked to console_scripts"? Are you referring to the packaging feature? https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html If you are, I expect that the answer for why some functions aren't linked to console_scripts could be that: 1. Not all functions would be useful as command line tools. 2. Nobody has done the work to make it possible. 3. If a Python package already defines a `__main__.py` file in the package, you can call it as a CLI tool with `python -m package`. So making it a separate CLI tool is redundant. In the case of packages that are part of the Python stdlib, linking them to a stand alone CLI tool is more of a decision for the OS than for Python itself. On Linux, I think that the Linux distribution decides whether or not to include CLI tools for Python, and what they are called (e.g. whether or not the commands "idle" and "pip" exist). I don't know what happens on Mac and Windows. There is some evidence that stand-alone scripts (such as pip, and idle) are harmful. If you have many different versions of Python installed, as some people do, calling pip is not guaranteed to install into the version you were expecting. Same for launching idle, which may not run the version of Python you were hoping for. For example, on my system, my preferred version of Python 3.10, but `pip` installs into 2.7, and `idle` doesn't exist at all. But I can run the correct versions with `python3 -m pip` and `python3 -m idlelib`. My guess is that you may get better answers to your question if you ask it on the Packaging Discussion forum: https://discuss.python.org/c/packaging/14 -- Steve