In python, how do I expose some command from my distutils package?

109 Views Asked by At

After installing django:

pip install django

I can immediately write:

django-admin.py startproject project

And django-admin.py is somehow known to my system.

I'm developing small webserver and distribute is using PIP - what should I put in my setup.py to expose my runserver.py file system-wide in the same manner as Django does?

1

There are 1 best solutions below

0
On

Use the scripts keyword to setup. For example:

setup(...,
      scripts=['django_admin.py']
      )

The script is required to be executable.

In some cases, an alternative is to specify a function in a module that should be an entry_point

setup(...,

    entry_points={
        'console_scripts':
             ['myscript = my.package.scripts:main'],
    }
}