本文主要是介绍理解console scripts entry point in Python,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
-
Entry points specification
开始之前,先看看《理解setuptools in Python》
Entry points are a mechanism for an installed distribution to advertise components it provides to be discovered and used by other code.
Conceptually, an entry point is defined by three required properties:
- The group that an entry point belongs to indicates that sort of object it provides.
- The name identifies this entry point within its group.
- The object reference points to a Python object.
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.
The most popular kind of entry point is the console_scripts entry point, which points a function that you want made available as a command-line tool to whoever installs your packages. This goes into your setup.py like :
entry_points={'console_scripts' : ['cursive = cursive.tools.cmd:cursive_command',], },
-
Entry point file format
Entry points
are defined in a file calledentry_points.txt
in the*.dist-info
directory of the distribution. This is the directory described in PEP 376 for installed distributions, and in PEP 427 for wheels. The file uses the UTF-8 character encoding. -
console_scripts vs. gui_scripts
Two groups of entry points have special significance in packaging:
-
console_scripts
-
gui_scripts
-
-
References
- PyPA : Entry points specification
- Explain Python entry points?
- Python Entry Points Explained
- Difference between entry_points/console_scripts and scripts in setup.py?
- Building and Distributing Packages with Setuptools
这篇关于理解console scripts entry point in Python的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!