Answer: Is there a way to "link" a python program from several files?

Edward A. Falk falk at green.rahul.net
Tue Mar 4 08:06:45 CET 2008


In article <92dc6954-6f9a-40b2-9cee-4bd46b9a2826 at f47g2000hsd.googlegroups.com>,
George Sakkis  <george.sakkis at gmail.com> wrote:
>
>What's so complicated about "python setup.py install" ? Even that is
>not strictly necessary for pure python packages; a user may just
>unpack the archive, cd to the extracted directory and execute the
>appropriate .py file(s).

Aha.  Completely forgot about setup.py.

Unfortunately, under Linux, all it seems to do is build a tarball for
me, which when unpacked produces several discrete .py files, leaving
me back where I started.

Anyway, I did what I should have done in the first place and trolled
/usr/bin to see how other people had done it.

It turns out there are a few answers:  First, you can simply just produce
the program as a single .py file (which is what I wound up doing).

Second, you can put all the .py files other than the "main" one into
/usr/share/<programname> and then append that directory to your
path before importing anything.

Third, you can put all the .py files other than the "main" one into
/usr/lib/python2.2/site-packages/<programname> and then you don't
have to modify your path.


The second and third methods have the advantage that you can have .pyc
files hanging around.


Anyway, thanks for all your input.

-- 
	-Ed Falk, falk at despams.r.us.com
	http://thespamdiaries.blogspot.com/



More information about the Python-list mailing list