Python – How to package a command line Python script


I've created a python script that's intended to be used from the command line. How do I go about packaging it? This is my first python package and I've read a bit about setuptools, but I'm still not sure the best way to do this.


I ended up using with the key configurations noted below:

mycommand = mypackage.mymodule:main

Here's a good example in context.

Best Solution

Rather than using setuptools non standard way of proceeding, it is possible to directly rely on distutils setup's function, using the scripts argument, as stated here:

from distutils import setup

It allows you to stay compatible a) with all python versions and b) not having to rely on a setuptools as an external dependency.