473,508 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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, fa**@despams.r.us.com
http://thespamdiaries.blogspot.com/
Feb 16 '08 #1
8 1571
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
Feb 16 '08 #2
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

Feb 16 '08 #3
"Brian Smith" <br***@briansmith.orgwrites:
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.
Feb 16 '08 #4
On Feb 16, 7:53 pm, f...@green.rahul.net (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

Feb 18 '08 #5
In article <0f**********************************@u72g2000hsf. googlegroups.com>,
BlueBird <ph**@freehackers.orgwrote:
>
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, fa**@despams.r.us.com
http://thespamdiaries.blogspot.com/
Feb 21 '08 #6
On Feb 21, 1:58 am, f...@green.rahul.net (Edward A. Falk) wrote:
In article <0f3e4884-59f8-4db8-a2a3-6f6d4fc14...@u72g2000hsf.googlegroups.com>,

BlueBird <p...@freehackers.orgwrote:
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
Feb 21 '08 #7
Edward A. Falk schrieb:
In article <0f**********************************@u72g2000hsf. googlegroups.com>,
BlueBird <ph**@freehackers.orgwrote:
>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
Feb 21 '08 #8
In article <92**********************************@f47g2000hsd. googlegroups.com>,
George Sakkis <ge***********@gmail.comwrote:
>
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/<programnameand 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/<programnameand 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, fa**@despams.r.us.com
http://thespamdiaries.blogspot.com/
Mar 4 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
17067
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited...
6
3262
by: Dave Patton | last post by:
Discussions in another thread, about the use of multiple "Top" links on a page prompted me to redo a page of mine: http://members.shaw.ca/davepatton/mapcompare.html was changed to:...
3
1588
by: bcanavan | last post by:
If I push/pull an xml file from/to a client pc across the internet, can Access link to it directly, or would I have to import the xml data to a table? If I have to import it, what features might...
10
7580
by: Ian Lazarus | last post by:
Hello. How do "unresolved token" link errors occur. How do I fix them? Linking... LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@ LINK : error LNK2020: unresolved token...
12
1892
by: Claude | last post by:
Hi, I've designed my own form checking code for name, address, email, comment box etc. What my client keeps getting in his consumer feedback forms is "spam" from companies who repeatedly...
0
1005
by: Learner | last post by:
Hello, we are using Master Pages in asp.net 2.0. Our Master page has three contentplaceholders. On the left most ContentPlaceHolder we have all the links for the navigation of the site. One of the...
0
873
by: pamelafluente | last post by:
Hi, Assume that I have a web application. I want to be able to use the classes that are in another project (say a Win application) on which I am working at the same time. Is it possible to...
33
2310
by: STILL LEARNING | last post by:
I'm not sure if this can even be done, but what prompts the question is my desire to be able to create an "Uber Link" script/code of some sort, such that even if the html page contains nothing but...
0
929
by: not_a_commie | last post by:
My software supports a plugin framework. The main plugin projects are included as projects in the main software VS2005 solution. However, they are not referenced by any of the other projects in the...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.