[distutils] Install script under a different name

Wolodja Wentland wentland at cl.uni-heidelberg.de
Sat Dec 5 06:37:40 EST 2009


On Fri, Dec 04, 2009 at 19:34 -0500, Nikolaus Rath wrote:
> All my Python files have extension .py. However, I would like to install
> scripts that are meant to be called by the user without the suffix, i.e.
> the file scripts/doit.py should end up as /usr/bin/doit.

> Apparently the scripts= option of the setup() function does not support
> this directly. Is there a clever way to get what I want?

Just name the file you want to install 'doit' and not 'doit.py'. That
would be the easiest way. You might run into problems on Windows though,
which IIRC (it's been a while) heavily relies on file suffixes and not
on their content. That might have changed in the last 10 years though,
so better check that first.

You can also use entry points to create the executable at install time.
Have a look at [1] which explains how this is done. This requires using
Distribute/setuptools though, ...

[1] http://packages.python.org/distribute/setuptools.html#automatic-script-creation
-- 
  .''`.     Wolodja Wentland    <wentland at cl.uni-heidelberg.de> 
 : :'  :    
 `. `'`     4096R/CAF14EFC 
   `-       081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/106234ae/attachment.sig>


More information about the Python-list mailing list