help on how to arrange python code

L

Luca Fini

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: (e-mail address removed)
-----------------------------+--------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,915
Members
47,456
Latest member
JavierWalp

Latest Threads

Top