help on how to arrange python code

Luca Fini lfini at arcetri.astro.it
Sat Oct 18 09:02:33 EDT 2003


I have to distribute a script (something to be run from command line)
which is actually made up of a file containing a "main" (let's call it:
dpu) and a few modules which are imported. Everything stays on a single
directory for developing purposes.

When I distribute the code to other machines, I'd like to have all those
files on a separate directory in .../site-pakages (or any other suitable
place), except the main script which should stay in /usr/local/bin.

So I'm trying to use distutils to distribute the thing as a package (named
"dpu") including a script (again named "dpu").

Everything is distributed as expected, but when I go to run the
application the import statements do not work. In fact  I have them as,
e.g.:

from info import *      # which works on my development directory

but to use the modules disptributed as a package I must write:

from dpu.info import *


Note that I cannot put my modules on a ./dpu subdir in the development
directory, because I'd like that the script name is "dpu" and it
conflicts with the package directory.

Has anybody hints on how to cope with the problem?

Many thanks,
					l.f.

--------------------------------------------------------------------------
       -- )     Luca Fini                            Tel: +39 055 2752 307
 ___    |\      INAF - Oss. Astrofisico di Arcetri   Fax: +39 055 2752 292
/   |   | |-_   L.go E.Fermi, 5 +-----------------------------------------
(___|___//___)  50125 Firenze  /   WWW: http://www.arcetri.astro.it/~lfini
 (_)      (_)   Italia        / e-mail: lfini at arcetri.astro.it
-----------------------------+--------------------------------------------




More information about the Python-list mailing list