Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is there a way to "link" a python program from several files?

Reply
Thread Tools

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

 
 
Edward A. Falk
Guest
Posts: n/a
 
      02-16-2008
IOW, is there a "linker" for python? I've written a program comprised of about
five .py files. I'd like to find a way to combine them into a single
executable. Obviously, I could hand-edit them into a single .py file, but
I'm looking for a way to keep them as seperate files for development but
distribute the result as a single file.

If this were C, I'd compile and link them and distribute the resulting
executable. I'm trying to do that, but for Python.

TIA,

--
-Ed Falk, http://www.velocityreviews.com/forums/(E-Mail Removed)
http://thespamdiaries.blogspot.com/
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      02-16-2008
Edward A. Falk schrieb:
> IOW, is there a "linker" for python? I've written a program comprised of about
> five .py files. I'd like to find a way to combine them into a single
> executable. Obviously, I could hand-edit them into a single .py file, but
> I'm looking for a way to keep them as seperate files for development but
> distribute the result as a single file.
>
> If this were C, I'd compile and link them and distribute the resulting
> executable. I'm trying to do that, but for Python.


Depending on the OS, there are several options. Ranging from
distributing an .egg (setuptools) over py2exe for windows to py2app on
OSX - and some more, e.g. cx_freeze.

Google for one of the above.

Diez
 
Reply With Quote
 
 
 
 
Brian Smith
Guest
Posts: n/a
 
      02-16-2008
Diez B. Roggisch wrote:
> Edward A. Falk schrieb:
> > IOW, is there a "linker" for python? I've written a
> > program comprised of about five .py files. I'd like to
> > find a way to combine them into a single executable.
> > Obviously, I could hand-edit them into a single
> > .py file, but I'm looking for a way to keep them as
> > seperate files for development but distribute the
> > result as a single file.


> Depending on the OS, there are several options. Ranging from
> distributing an .egg (setuptools) over py2exe for windows to
> py2app on OSX - and some more, e.g. cx_freeze.


I would be interested in a program that can combine multiple modules
into a single module, which removes all the inter-package imports and
fixes other inter-module references, like Haskell All-in-One does for
Haskell: http://www.cs.utah.edu/~hal/HAllInOne/index.html

- Brian

 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      02-16-2008
Brian Smith schrieb:
> Diez B. Roggisch wrote:
>> Edward A. Falk schrieb:
>>> IOW, is there a "linker" for python? I've written a
>>> program comprised of about five .py files. I'd like to
>>> find a way to combine them into a single executable.
>>> Obviously, I could hand-edit them into a single
>>> .py file, but I'm looking for a way to keep them as
>>> seperate files for development but distribute the
>>> result as a single file.

>
>> Depending on the OS, there are several options. Ranging from
>> distributing an .egg (setuptools) over py2exe for windows to
>> py2app on OSX - and some more, e.g. cx_freeze.

>
> I would be interested in a program that can combine multiple modules
> into a single module, which removes all the inter-package imports and
> fixes other inter-module references, like Haskell All-in-One does for
> Haskell: http://www.cs.utah.edu/~hal/HAllInOne/index.html


won't happen for python. python relies heavily on modules/packages being
namespaces.

Why would you want such a beast anyway? If it's about
single-file-distribution, that is solved by some of the above mentioned
tools - or even not desired anyway (say OS X bundles)

Diez
 
Reply With Quote
 
Brian Smith
Guest
Posts: n/a
 
      02-16-2008
Diez B. Roggisch wrote:
> Brian Smith wrote:
> > I would be interested in a program that can combine
> > multiple modules into a single module, which removes
> > all the inter-package imports and fixes other
> > inter-module references, like Haskell
> > All-in-One does for Haskell:
> > http://www.cs.utah.edu/~hal/HAllInOne/index.html

>
> won't happen for python. python relies heavily on
> modules/packages being namespaces.


So does Haskell. Haskell All-In-One handles that by renaming every
top-level artifact.

> Why would you want such a beast anyway? If it's about
> single-file-distribution, that is solved by some of the above
> mentioned tools - or even not desired anyway (say OS X bundles)


I want to package a complex WSGI application into a single CGI script,
so that users can copy the script into some CGI-enabled directory and
have it work without any further configuration, and so that it runs
faster (especially when the file is on NFS). If it is possible to run an
egg as a CGI (without modifying the web server configuration file), then
that would work as well.

- Brian

 
Reply With Quote
 
Paul Rubin
Guest
Posts: n/a
 
      02-16-2008
"Brian Smith" <(E-Mail Removed)> writes:
> So does Haskell. Haskell All-In-One handles that by renaming every
> top-level artifact.


That can't be done reliably in python because namespaces are dynamic.

> If it is possible to run an egg as a CGI (without modifying the web
> server configuration file), then that would work as well.


This would be an interesting enhancement.
 
Reply With Quote
 
BlueBird
Guest
Posts: n/a
 
      02-18-2008
On Feb 16, 7:53 pm, (E-Mail Removed) (Edward A. Falk) wrote:
> IOW, is there a "linker" for python? I've written a program comprised of about
> five .py files. I'd like to find a way to combine them into a single
> executable.


I wrote a small wiki page to sum-up my findings about such typical
problem:

http://www.freehackers.org/Packaging_a_python_program

 
Reply With Quote
 
Edward A. Falk
Guest
Posts: n/a
 
      02-21-2008
In article <(E-Mail Removed)>,
BlueBird <(E-Mail Removed)> wrote:
>
>I wrote a small wiki page to sum-up my findings about such typical
>problem:
>
>http://www.freehackers.org/Packaging_a_python_program
>


Excellent references, but maybe a bit of overkill. Everybody in my
target audience has python on their systems, I just want to send a
single .py (or .pyc) file so there's no complicated install procedure.

I mean, how *are* large python programs normally distributed under Linux?

--
-Ed Falk, (E-Mail Removed)
http://thespamdiaries.blogspot.com/
 
Reply With Quote
 
George Sakkis
Guest
Posts: n/a
 
      02-21-2008
On Feb 21, 1:58 am, (E-Mail Removed) (Edward A. Falk) wrote:
> In article <(E-Mail Removed)>,
>
> BlueBird <(E-Mail Removed)> wrote:
>
> >I wrote a small wiki page to sum-up my findings about such typical
> >problem:

>
> >http://www.freehackers.org/Packaging_a_python_program

>
> Excellent references, but maybe a bit of overkill. Everybody in my
> target audience has python on their systems, I just want to send a
> single .py (or .pyc) file so there's no complicated install procedure.


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).

George
 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      02-21-2008
Edward A. Falk schrieb:
> In article <(E-Mail Removed)>,
> BlueBird <(E-Mail Removed)> wrote:
>> I wrote a small wiki page to sum-up my findings about such typical
>> problem:
>>
>> http://www.freehackers.org/Packaging_a_python_program
>>

>
> Excellent references, but maybe a bit of overkill. Everybody in my
> target audience has python on their systems, I just want to send a
> single .py (or .pyc) file so there's no complicated install procedure.
>
> I mean, how *are* large python programs normally distributed under Linux?


By means of their package management. At least that's what many people
prefer.

But I don't get what's wrong with


you: python setup.py bdist_egg

your client: easy_install the.egg



Diez
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to step debug the multiprocessing python program? davy zhang Python 1 11-08-2008 03:28 AM
What is a good way of having several versions of a python moduleinstalled in parallell? Joel Hedlund Python 11 09-27-2007 01:24 PM
Is there a way to program a robot with python (ex, an electric motor, control it's speed, etc) socialanxiety@gmail.com Python 11 07-09-2007 09:12 AM
RDOC: several related modules in several C files Victor \Zverok\ Shepelev Ruby 3 03-16-2007 04:15 PM
[python] Is there a python written fax program out there? David Stockwell Python 2 06-08-2004 08:28 PM



Advertisments