473,883 Members | 1,576 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 1603
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***@briansmi th.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.rahu l.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************ *************** *******@u72g200 0hsf.googlegrou ps.com>,
BlueBird <ph**@freehacke rs.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.rahu l.net (Edward A. Falk) wrote:
In article <0f3e4884-59f8-4db8-a2a3-6f6d4fc14...@u7 2g2000hsf.googl egroups.com>,

BlueBird <p...@freehacke rs.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************ *************** *******@u72g200 0hsf.googlegrou ps.com>,
BlueBird <ph**@freehacke rs.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************ *************** *******@f47g200 0hsd.googlegrou ps.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/<programnamea nd 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/<programnamea nd 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
17099
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 link and the text of the link under the cursor are red. All other links should be white. The problem with the construction above is that a visited link remains for the rest of the session red regardless wether it was visited 17 clicks back in...
6
3293
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: http://members.shaw.ca/davepatton/mapcompareX.html Part of the changes were as the result of some comments by Alan J. Flavell :-) Is the use of the links in the head of the document valid? I'm using Mozilla 1.3, and they make sense to me for its
3
1606
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 Access have that would allow me to automate the import? Thanks, Bob
10
7620
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 (0A000016) _CxxThrowException LINK : error LNK2020: unresolved token (0A000018) exception.__ctor LINK : error LNK2020: unresolved token (0A000019) exception.__ctor LINK : error LNK2020: unresolved token (0A00001A) exception.__dtor LINK : error...
12
1938
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 insert their hyperlinks in all fields, of course along with their "hype"... Is is possible with Javascript to refuse form contents whose strings contain
0
1025
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 links on it is "Admin" link. Now, if some one with "Admin" Role logs in and clicks on it then the "Admin" link should populate all the other links underneath the "Admin" link. I am looking for some thing like toggel link. Can some one please...
0
885
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 "include as link" the files of the win application in the web application?
33
2412
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 a background image -or- a background color -- in other words, the page has neither content nor placed images -- any click, ANYWHERE, will launch the URL in your browser. I realize I can make traditional text links and graphics links; what I'm...
0
944
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 solution. Currently, I have the main startup project (aka, executing assembly) "add as link" the "myPlugin\bin\debug\myPlugin.dll" for each of my plugins. This is nice because it has the ability to "copy if newer". This is crappy because it...
0
9793
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10752
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10858
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9582
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7974
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7134
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5996
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.