Re: howto pack python programs
- To: Bastian Venthur <email@example.com>
- Subject: Re: howto pack python programs
- From: Volker Grabsch <firstname.lastname@example.org>
- Date: Sun, 26 Mar 2006 19:15:12 +0200
- Message-id: <20060326171512.GA10909@flap>
- In-reply-to: <email@example.com>
- References: <firstname.lastname@example.org>
On Sun, Mar 26, 2006 at 04:33:37PM +0200, Bastian Venthur wrote:
> Is the location /usr/share/$PACKAGE OK? Should I create the symlinks
> without the py-extension, like:
> /usr/bin/ex1 -> /u/s/ex1.py
I think this is the better solution. A "/usr/bin/ex1.py" would take
away some freedom. Maybe you decide later to use a wrapper script
/usr/bin/ex1 (shell script or python script).
However, there's even a more portable, generic, better solution
I'll try to explain.
> Next problem, lintian is complaining (W) about non-executable scripts in
> /usr/share/$PACKAGE -- can I ignore this?
You shouldn't. I don't believe that your Python code really belongs
You should consider providing a setup.py script, and use this to install
your code. But I'm not sure whether this is in the spirit of the Debian
setup.py would install your python code into:
To avoid cluttering the "site-packages/" you may consider using a
"python package", i.e. a sub directory containing your *.py files.
I suggest you to layout your source directory like this:
Where ex*.py are executable and myprog/ex*.py aren't.
The ex*.py are wrappers that look like this:
or like this, depending on your code:
These wrappers may be able to run from the source directory as
well as from /usr/bin/ (provided that your myprog/ package is
installed to .../site-packages/)
However, if your myprog/ex*.py file *are* currently just wrappers
to the functionality of foo.py, baz.py, etc., then just put them
directly into your source package an install them to /usr/bin, i.e.
Everything I described until here has nothing to do with
Debian, it's just to provide a source package for general use.
Maybe there are better recommendations in the net, "best
practices". If you find some, please let me know, I didn't
find any. :-)
For Debian, put the ex*.py files to /usr/bin/ex* (without ".py")
and the rest to whatever setup.py recommends, i.e. just do:
./setup.py install --prefix="debian/tmp/usr"
If your setup.py looks like this:
from distutils.core import setup
... then it will install your modules to .../site-packages/myprog/*
and your ex*.py files to .../usr/bin/. Distutils will also adjust the
sh'bang line of your ex*.py to the current interpreter location.
However, it won't rename your ex*.py to ex*, so you'd have to do
this in your "debian/myprog.install" with something like this:
(maybe ... I'm not sure)
Whatever you do, I'm very interested in your result. I'll have a similar
challenge to master when I find more time. My current recommendations
on a similar problem can be found at:
(how to deal with non-python files, where to put them, etc. in a
platform independent manner)
It's currently only in german, but I'd translate this if someone is