Entry Points ¶ Entry points are a type of metadata that can be exposed by packages on installation. They are a very useful feature of the Python ecosystem, and come specially handy in two scenarios: 1. The package would like to provide commands to be run at the terminal.
This functionality is known as console scripts. I'm trying to add a pyproject.toml to a project that's been using setup.py in order to enable support by pipx. I'd like to specify the command line scripts the project includes in pyproject.toml, but all the guides I can find give instructions for use with poetry, which I am not using.
Entry Points | PDF
I also don't want to specify entry points to modules. Entry points specification ¶ Entry points are a mechanism for an installed distribution to advertise components it provides to be discovered and used by other code. For example: Distributions can specify console_scripts entry points, each referring to a function.
When pip (or another console_scripts aware installer) installs the distribution, it will create a command. The console_scripts Entry Point ¶ The second approach is called an 'entry point'. Setuptools allows modules to register entrypoints which other packages can hook into to provide certain functionality.
PPT - Entry Points into a UX project PowerPoint Presentation, free ...
It also provides a few itself, including the console_scripts entry point. In conclusion, both entry_points/console_scripts and scripts provide ways to define command. Entry points If you have any functions in your package that you would like to expose to be used as a command-line utility, you can add them to the console_scripts entry points.
For example, if you have a function called main in example_module.py, then adding this to your setup.cfg will allow users to run my-example-utility as a shell command. The pyproject metadata keys and the [build-system] table may be filled in as described in Writing your pyproject.toml, adding a dependency on typer (this tutorial uses version 0.12.3). For the project to be recognised as a command-line tool, additionally a console_scripts entry point (see Creating executable scripts) needs to be added as a subkey.
Project Entry
When resolving these metadata keys, setuptools will look for tool.setuptools.dynamic.entry-points, and use the values of the console_scripts and gui_scripts entry-point groups. [3] (1, 2) In the context of this document, directives are special TOML values that are interpreted differently by setuptools (usually triggering an associated function). It also provides a few itself, including the console_scripts entry point.
This allows Python functions (not scripts!) to be directly registered as command-line accessible tools! -> setup.py. The [project.scripts] table corresponds to the console_scripts group in the entry points specification. The key of the table is the name of the entry point and the value is the object reference.