Zuork Ideas

Setup Py Entry_points Console_scripts

Entry Points ¶ Entry points are a type of metadata that can be exposed by packages on installation.

Setup Py Entry_points Console_scripts
What is setup.py? - Be on the Right Side of Change
What is setup.py? - Be on the Right Side of Change
What is setup.py? - Be on the Right Side of Change
What is setup.py? - Be on the Right Side of Change

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.

Create and run setup.py | PyCharm Documentation
Create and run setup.py | PyCharm Documentation

This functionality is known as console scripts. 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 console_scripts Entry Point ¶ The second approach is called an 'entry point'.

PY-Entry point
PY-Entry point

Setuptools allows modules to register entrypoints which other packages can hook into to provide certain functionality. It also provides a few itself, including the console_scripts entry point. This allows Python functions (not scripts!) to be directly registered as command.

python - How to set the bin scripts entry point in `setup.py`? - Stack Overflow
python - How to set the bin scripts entry point in `setup.py`? - Stack Overflow

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.

python - Conditional setuptools entry_points - Stack Overflow
python - Conditional setuptools entry_points - Stack Overflow

The entry_points/console_scripts option is a feature provided by the setuptools package, which is commonly used for packaging and distributing Python projects. It allows you to define command. Packages may provide commands to be run at the console (console scripts), such as the pip command.

Support module __main__.py through python -m (entry points/console scripts) · Issue #1995 · pypa ...
Support module __main__.py through python -m (entry points/console scripts) · Issue #1995 · pypa ...

These commands are defined for a package as a specific kind of entry point in the setup.cfg or setup.py. The underlying difference between the two scripts vs entry_points -> console_scripts in setup.py is fairly "easy" to see if you build a wheel and do unzip. python Setuptools entry points When building a Python package, the most common way of exposing a command line interface (CLI) is to use the "scripts" keyword in setup.py.

Entry Points
Entry Points

The setup function has many options, the one I want to talk about is the entry_points keyword. The most typical example of an entry point is the so called console_scripts entry point. Here an example from pytest's setup.py.

Load Site Average 0,422 sec