1

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:

  1. user installs package via pip
pip install my-pkg
  1. once installed the user can enter the following in their termial
my-pkg start
  1. this then creates a settings.py/index.html files in the current dir

This is similar to running django-admin startproject. Thanks for any help.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

... if OP is using setup.py... This is done in other ways in other tools (for example poetry's pyproject.toml)
0

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',                  
        ], 
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.