Re: making symlinks with distutils

From: Sylvain Thenault (sylvain.thenault_at_logilab.fr)
Date: 02/04/05


Date: Fri, 04 Feb 2005 11:59:22 +0100

On Fri, 04 Feb 2005 02:45:34 -0800, Michele Simionato wrote:

> I want to distribute a pure Python package with this structure:
>
>> mypackage
>> __init__.py
>> module1.py
>> module2.py
>> ...
>> myexecutable.py
>
> In particular, myexecutable.py is a script which is intended to be used
> from the command line via the shebang trick. I want to distribute on
> Unices.
> and I want a symlink
>
> /usr/bin/myexecutable -> <package-path>/mypackage/myexecutable.py
>
> to be made at installation time, when the user runs "python setup.py
> install".
>
> What is the recommanded way to do that? Do I need a postinstallation
> script or something like that?
>
> I could do that in various way, but I don't see the obvious one, maybe
> because I am not a Dutch ;)

i'm not sure there is a standard way to do so with distutils.
My current way to handle executable scripts is to have a run() function in
the myexecutable.py module, and then to have a very simple myexecutable
script with the following content:

#!/usr/bin/python
from mypackage import myexecutable
myexecutable.run()

And then register this script using distutils'"scripts" keyword argument.
This has the advantage that I can also create a very simple .bat file for
windows users without code duplication.

-- 
Sylvain Thénault                               LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org


Relevant Pages

  • Re: loading a DLL in a Tcl extension
    ... It is always a good idea to refactor mydll.dll so that you do: ... package require MyPackage 1.0 ... Than you have a script and a directory with your dll's ...
    (comp.lang.tcl)
  • Re: loading a DLL in a Tcl extension
    ... package require MyPackage 1.0 ... Than you have a script and a directory with your dll's ...
    (comp.lang.tcl)
  • Re: Is Mac a security hazard in a Windows network
    ... I'd also suggest you run a script after you're finished browsing a Windows ... box to clear out Mac files which are only visible to Windows users. ...
    (comp.sys.mac.system)
  • Progress Box or Bar in Windows
    ... I have a Python script that I've prettied-up for Windows users by adding things like shell.SHBrowseForFolder and win32gui.MessageBox, ... win32gui.MessageBox informing user the script will now begin. ... a progress bar that moves across the screen as the script does its job. ...
    (comp.lang.python)
  • making symlinks with distutils
    ... I want to distribute a pure Python package with this structure: ... myexecutable.py is a script which is intended to be used ... from the command line via the shebang trick. ... to be made at installation time, when the user runs "python setup.py ...
    (comp.lang.python)