I'm working on a Python package, and I'd like to add a script to the users PATH once they install it. I'm not sure if this is the correct terminology, so here's an example of what I'd like to accomplish:
pip install my-pkg
my-pkg start
This is similar to running django-admin startproject
. Thanks for any help.
You can do this by specifying that script in your setup.py
as an entrypoint .
If using a pyproject.toml, the equivalent is a plugin .
Just to expand on @Ray Johns answer, this is what it would look like inside your setuptools.setup
function.
entry_points = {
'console_scripts': [
'command = my-pkg.module:func',
],
}
I'm working on a Python package, and I'd like to add a script to the users PATH once they install it. I'm not sure if this is the correct terminology, so here's an example of what I'd like to accomplish:
pip install my-pkg
my-pkg start
This is similar to running django-admin startproject
. Thanks for any help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.