43

My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py into site-packages or somewhere similar..

Can I make setup.py install tvnamer.py as tvnamer, and/or is there a better way of installing command-line applications?

Worm
  • 1,313
  • 2
  • 11
  • 28
dbr
  • 165,801
  • 69
  • 278
  • 343
  • Does this answer your question? [setup.py and adding file to /bin/](https://stackoverflow.com/questions/4840182/setup-py-and-adding-file-to-bin) – user202729 Dec 06 '21 at 06:31

1 Answers1

38

Try the entry_points.console_scripts parameter in the setup() call. As described in the setuptools docs, this should do what I think you want.

To reproduce here:

from setuptools import setup

setup(
    # other arguments here...
    entry_points = {
        'console_scripts': [
            'foo = package.module:func',
            'bar = othermodule:somefunc',
        ],
    }
)
dbr
  • 165,801
  • 69
  • 278
  • 343
Blair Conrad
  • 233,004
  • 25
  • 132
  • 111
  • 8
    When I try this with Python 2.6 and 3.1, I get a message `UserWarning: Unknown distribution option: 'entry_points'`. So I guess it's not supported in the `distutils` that comes with Python (2.6 and 3.1). So, is it okay to use this option if we want to distribute on PyPI? – Craig McQueen Mar 17 '10 at 01:04
  • 6
    on Ubuntu 11.04, install python-setuptools. Make sure you setup.py is importing: 'from setuptools import setup' – cmcginty Jun 12 '11 at 00:18