tags:

views:

47

answers:

2

I need to install a python module in the site packages that also will be used as a command line application. Suppose I have a module like:

app.py

def main():
  print 'Dummy message'

if __name__ == '__main__':
    main()

setup.py

 import distutils

 try:
   from setuptools import setup
 except ImportError:
   from distutils.core import setup

 if __name__ == '__main__':

    setup(name = 'dummy',
            version = '1.0',
            packages = ['dummy'],
    )

Creating the dist by:

    setup.py sdist

Install:

    setup.py install

And now I would like to use it as a command line application by opening the command window and typing just: dummy

Is it possible to create such application under windows without to carry out registering system pat variables and so on ...

A: 

Put the following in dummy.cmd:

python.exe -m dummy

Or is it dummy.app...

Oh well, it's one of those.

Ignacio Vazquez-Abrams
Wow, and thats all?Shell I include this to the package distribution as well?
koleto
I personally wouldn't bother, because it's just so not difficult.
Ignacio Vazquez-Abrams
+2  A: 

You can use the options in setup.py to declare command line scripts. Please refer to this article. On Windows, the script will be created in "C:\Python26\Scripts" (if you didn't change the path) - lots of tools store their scripts there (e.g. "easy_install", "hg", ...).

AndiDog
Supper! Thanks!
koleto