An "entry point" is typically a function (or other callable function-like object) that a developer or user of your Python package might want to use, though a non-callable object can be supplied as an entry point as well (as correctly pointed out in the comments!).

The most popular kind of entry point is the console_scripts entry point, which points to a function that you want made available as a command-line tool to whoever installs your package. This goes into your setup.py script like:

entry_points={
    'console_scripts': [
        'cursive = cursive.tools.cmd:cursive_command',
    ],
},

I have a package I've just deployed called cursive.tools, and I wanted it to make available a "cursive" command that someone could run from the command line, like:

$ cursive --help
usage: cursive ...

The way to do this is define a function, like maybe a cursive_command function in the file cursive/tools/cmd.py that looks like:

def cursive_command():
    args = sys.argv[1:]
    if len(args) < 1:
        print "usage: ..."

and so forth; it should assume that it's been called from the command line, parse the arguments that the user has provided, and ... well, do whatever the command is designed to do.

Install the docutils package for a great example of entry-point use: it will install something like a half-dozen useful commands for converting Python documentation to other formats.

Answer from Brandon Rhodes on Stack Overflow
🌐
PyPA
setuptools.pypa.io › en › latest › userguide › entry_point.html
Entry Points - setuptools 84.0.0 documentation
The recommended approach for loading and importing entry points is the importlib.metadata module, which is a part of the standard library since Python 3.8 and is non-provisional since Python 3.10. For older versions of Python, its backport importlib_metadata should be used.
Top answer
1 of 3
297

An "entry point" is typically a function (or other callable function-like object) that a developer or user of your Python package might want to use, though a non-callable object can be supplied as an entry point as well (as correctly pointed out in the comments!).

The most popular kind of entry point is the console_scripts entry point, which points to a function that you want made available as a command-line tool to whoever installs your package. This goes into your setup.py script like:

entry_points={
    'console_scripts': [
        'cursive = cursive.tools.cmd:cursive_command',
    ],
},

I have a package I've just deployed called cursive.tools, and I wanted it to make available a "cursive" command that someone could run from the command line, like:

$ cursive --help
usage: cursive ...

The way to do this is define a function, like maybe a cursive_command function in the file cursive/tools/cmd.py that looks like:

def cursive_command():
    args = sys.argv[1:]
    if len(args) < 1:
        print "usage: ..."

and so forth; it should assume that it's been called from the command line, parse the arguments that the user has provided, and ... well, do whatever the command is designed to do.

Install the docutils package for a great example of entry-point use: it will install something like a half-dozen useful commands for converting Python documentation to other formats.

2 of 3
234

EntryPoints provide a persistent, filesystem-based object name registration and name-based direct object import mechanism (implemented by the setuptools package).

They associate names of Python objects with free-form identifiers. So any other code using the same Python installation and knowing the identifier can access an object with the associated name, no matter where the object is defined. The associated names can be any names existing in a Python module; for example name of a class, function or variable. The entry point mechanism does not care what the name refers to, as long as it is importable.

As an example, let's use (the name of) a function, and an imaginary python module with a fully-qualified name 'myns.mypkg.mymodule':

def the_function():
   "function whose name is 'the_function', in 'mymodule' module"
   print "hello from the_function"

Entry points are registered via an entry points declaration in setup.py. To register the_function under entrypoint called 'my_ep_func':

    entry_points = {
        'my_ep_group_id': [
            'my_ep_func = myns.mypkg.mymodule:the_function'
        ]
    },

As the example shows, entry points are grouped; there's corresponding API to look up all entry points belonging to a group (example below).

Upon a package installation (ie. running 'python setup.py install'), the above declaration is parsed by setuptools. It then writes the parsed information in special file. After that, the pkg_resources API (part of setuptools) can be used to look up the entry point and access the object(s) with the associated name(s):

import pkg_resources

named_objects = {}
for ep in pkg_resources.iter_entry_points(group='my_ep_group_id'):
   named_objects.update({ep.name: ep.load()})

Here, setuptools read the entry point information that was written in special files. It found the entry point, imported the module (myns.mypkg.mymodule), and retrieved the_function defined there, upon call to pkg_resources.load().

Calling the_function would then be simple:

>>> named_objects'my_ep_func'
hello from the_function

Thus, while perhaps a bit difficult to grasp at first, the entry point mechanism is actually quite simple to use. It provides an useful tool for pluggable Python software development.

Discussions

Setuptools entry_points: invoking OS command - Packaging - Discussions on Python.org
I have a Python package that creates lots of log files. I can delete the log files using the below git command: git clean -f -x "*MainProcess.log" I would like to add this as an entry_point console “script” to the package’s setup.py. I see that entry_point is designed to invoke a Python ... More on discuss.python.org
🌐 discuss.python.org
0
February 10, 2022
python - setuptools 'entry_points' parameter usage - Stack Overflow
Looking through some python code, ive found an argument entry_points to the setuptools.setup function. I cant see this argument in any of the API docs for setuptools / distutils. Can anyone clarify... More on stackoverflow.com
🌐 stackoverflow.com
entry_point in setup.cfg with a src-layout project
My folders and files are structured with the src-layout. I tried to adapt the setuptools-docu about entry-points to it but fail. hyperorg ├── src │ └── hyperorg │ ├── __init__.py │ └── __main__.py ... More on github.com
🌐 github.com
2
1
The terrible magic of setuptools
I am the pusher robot. I push the packages down the stairs. More on reddit.com
🌐 r/Python
8
19
July 15, 2009
🌐
Python Packaging
packaging.python.org › specifications › entry-points
Entry points specification - Python Packaging User Guide
The entry point file format was originally developed to allow packages built with setuptools to provide integration point metadata that would be read at runtime with importlib.metadata.
🌐
Readthedocs
python-packaging.readthedocs.io › en › latest › command-line-scripts.html
Command Line Scripts — Python Packaging Tutorial
setup( ... entry_points = { 'console_scripts': ['funniest-joke=funniest.command_line:main'], } ... ) Again, once the package has been installed, we can use it in the same way. Setuptools will generate a standalone script ‘shim’ which imports your module and calls the registered function.
🌐
GitHub
github.com › ninjaaron › fast-entry_points
GitHub - ninjaaron/fast-entry_points: make entry_points specified in setup.py load more quickly.
Using entry_points in your setup.py makes scripts that start really slowly because it imports pkg_resources, which is a horrible thing to do if you want your trivial script to execute more or less instantly. Check it out: pypa/setuptools#510
Starred by 122 users
Forked by 18 users
Languages: Python 100.0% | Python 100.0%
🌐
Python.org
discuss.python.org › packaging
Setuptools entry_points: invoking OS command - Packaging - Discussions on Python.org
February 10, 2022 - I have a Python package that creates lots of log files. I can delete the log files using the below git command: git clean -f -x "*MainProcess.log" I would like to add this as an entry_point console “script” to the package’s setup.py. I see that entry_point is designed to invoke a Python function inside a module, can it also be used to invoke an OS command?
🌐
Rachum
amir.rachum.com › amir rachum's blog › python entry points explained
Python Entry Points Explained - Amir Rachum's
July 28, 2017 - When you create a distribution for a Python package, you need to have a setup.py file that contains the package’s name, dependencies, etc. It can also be used to register entry points and it looks like this: from setuptools import setup setup( name='snek', entry_points={ 'console_scripts': [ 'snek = snek:main', ], } )
🌐
Chriswarrick
chriswarrick.com › blog › 2014 › 09 › 15 › python-apps-the-right-way-entry_points-and-scripts
Python Apps the Right Way: entry points and scripts | Chris Warrick
September 15, 2014 - This is the real deal: create the entry points in your setup.py file. ... You must use setuptools, otherwise this won’t work.
Find elsewhere
🌐
ACM@UIUC TIL
til.acm.illinois.edu › python › setuptools_entry_points
Setuptools entry points | ACM@UIUC TIL
April 29, 2025 - # file: setup.py from setuptools import setup setup( name='my_package', entry_points={ 'console_scripts': [ 'my_cli': 'my_package.cli:main' ] }, ...
🌐
Pylonsproject
docs.pylonsproject.org › projects › pylons-webframework › en › latest › advanced_pylons › entry_points_and_plugins.html
Using Entry Points to Write Plugins — Pylons Framework 1.0.2 documentation
It is also possible to specify the entry points as a Python dictionary rather than a string if that approach is preferred. There are two more things we need to do to complete the plugin. The first is to include an ez_setup module so that if the user installing the plugin doesn’t have setuptools installed, it will be installed for them.
🌐
Pages from the fire
kaushikghose.wordpress.com › 2014 › 11 › 25 › python-setuptools-entry-points
Python setuptools entry points – Pages from the fire
September 15, 2015 - ... entry_points={ .... # Command line scripts 'console_scripts': ['runme = dothis:cli'] }, ... This has several advantages, mainly relating to playing nicely with both POSIX and Windows systems. There are also options for distributing Python GUI programs! Setuptools gives us a really nice way to implement a plugin system without us having to write any plugin manager that keeps track of where plugins are stored and how to import them (Relative import?
🌐
Setuptools
setuptools.pypa.io › en › stable › userguide › entry_point.html
Entry Points - setuptools 80.9.0.post20250527 documentation
The recommended approach for loading and importing entry points is the importlib.metadata module, which is a part of the standard library since Python 3.8 and is non-provisional since Python 3.10. For older versions of Python, its backport importlib_metadata should be used.
🌐
Benjamintoll
benjamintoll.com › 2021 › 04 › 04 › on-python-entry_points
On Python entry_points - benjamintoll.com
April 4, 2021 - For example, the entry_points specification allows for anything to be declared as a group in the setuptools configuration to which programs can register entry points, and pip and any other tool that has implemented the spec will create a wrapper for each entry and place it in the Python path.
🌐
YouTube
youtube.com › new zealand python user group
Demystefying Setuptools Entry Points - YouTube
Phoenix Zerin https://nz.pycon.org/schedule/presentation/180/ Entry points are one of the most powerful, yet mysterious, ways to customise the behaviour of P...
Published: December 7, 2017
Views: 2K
🌐
Upmf-grenoble
transit.iut2.upmf-grenoble.fr › doc › python-setuptools-doc › html › userguide › entry_point.html
Entry Points — Python documentation
The recommended approach for loading and importing entry points is the importlib.metadata module, which is a part of the standard library since Python 3.8. For older versions of Python, its backport importlib_metadata should be used.
🌐
DOKK
dokk.org › documentation › python-setuptools › v59.8.0 › userguide › entry_point
Entry Points - setuptools 59.8.0.post20231223.post-20231223 documentation
For a project wishing to solicit entry points, Setuptools recommends the importlib.metadata module (part of stdlib since Python 3.8) or its backport, importlib_metadata.
🌐
Tpleyer
blog.tpleyer.de › posts › 2017-12-13-Python-setup-py-entry-points.html
Python setup.py entry points - Tobi's blog
December 13, 2017 - When pytest is run, it will parse and import every entry point registered for its group and feed it with data via a hook mechanism based on certain events happening during program execution. # The example taken from pytest's documentation # sample ./setup.py file from setuptools import setup setup( name="myproject", packages = ['myproject'] # the following makes a plugin available to pytest entry_points = { 'pytest11': [ 'name_of_plugin = myproject.pluginmodule', ] }, # custom PyPI classifier for pytest plugins classifiers=[ "Framework :: Pytest", ], )
🌐
Abrah
justin.abrah.ms › python › setuptools-entrypoints-explained.html
Setuptools Entrypoints Explained
August 23, 2014 - In your setup.py, you defined a property called entry_points which is a dictionary mapping the entry point key to a list of values. The values take the form of .py = imhotep_pylint.plugin:PyLint. This is another mapping in string form from a user-defined string to a dotted module name (and ...