Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > build a static executable program with python

Reply
Thread Tools

build a static executable program with python

 
 
Torsten Mohr
Guest
Posts: n/a
 
      12-30-2004
Hi,

i'd like to build an executable file that is linked with
a python library and executes a script via PyRun_SimpleString
or similar functions.

Is there a static library of python available, so the users
don't need to install python?


What about DLL modules, do i just need to compile them
as a static lib, link them together with my program and
call their init function?


What about python modules, can i just use a tool like
"freeze" or "py2exe" to break up the import hierarchy
and call them before my script?


Is there some more information about building a static
executable available?


Thanks for any hints,
Torsten.

 
Reply With Quote
 
 
 
 
David Fraser
Guest
Posts: n/a
 
      12-30-2004
Torsten Mohr wrote:
> Hi,
>
> i'd like to build an executable file that is linked with
> a python library and executes a script via PyRun_SimpleString
> or similar functions.
>
> Is there a static library of python available, so the users
> don't need to install python?
>
>
> What about DLL modules, do i just need to compile them
> as a static lib, link them together with my program and
> call their init function?
>
>
> What about python modules, can i just use a tool like
> "freeze" or "py2exe" to break up the import hierarchy
> and call them before my script?
>
>
> Is there some more information about building a static
> executable available?
>
>
> Thanks for any hints,
> Torsten.
>

Just have a look at py2exe, it does basically what you're asking for -
see the link to the wiki from the py2exe home page for more information...

David
 
Reply With Quote
 
 
 
 
Adal Chiriliuc
Guest
Posts: n/a
 
      12-30-2004
My app uses Python 2.4 and the Pythonwin GUI (Python MFC wrapper).
I build it as a single exe file with everything linked in it. It's
a lot smaller than all the DLL's put together.

The Python modules are also put into the file as a Win32 resource
which contains all the modules bz2 compressed. I gather the required
modules the same way as py2exe does (using modulefinder), then I
compile them to .pyc files, bundle them all together in one file with
some information (like size and name) and than bzip compress the whole
file. When the app starts it uncompresses them and init's the
PyImport_FrozenModules variable (just like in freeze).

So I only have one exe file to ship, which contains everything needed.
Right now it's size is 2 MB, but bear in mind that it contains STLport
and Crypto++ which are big libraries. It compresses down to under 1 MB.

It's not very difficult to do if you have some experience. But you do
have to tweak some Python header files (to disable for example the
normal link against python24.lib).

You are right about the DLL modules. You just compile tham as a static
lib and manually call their's their's init function, AND ALSO THE
DllMain ONE. The exe file will still export the DLL functions, but you
can disable this with some tweaks.

Hope that helps. I can guide you through the process if you wish.

On Thursday, December 30, 2004 Torsten Mohr wrote:
> Hi,


> i'd like to build an executable file that is linked with
> a python library and executes a script via PyRun_SimpleString
> or similar functions.


> Is there a static library of python available, so the users
> don't need to install python?


> What about DLL modules, do i just need to compile them
> as a static lib, link them together with my program and
> call their init function?



> What about python modules, can i just use a tool like
> "freeze" or "py2exe" to break up the import hierarchy
> and call them before my script?



> Is there some more information about building a static
> executable available?



> Thanks for any hints,
> Torsten.




 
Reply With Quote
 
Torsten Mohr
Guest
Posts: n/a
 
      12-30-2004
Hi,

thank you very much for that detailled description.
I will try to get as far as i can with this information and
get back to you if i have any questions.


Thanks a lot,
Torsten.

 
Reply With Quote
 
Torsten Mohr
Guest
Posts: n/a
 
      12-30-2004
Hi Adal,

can you send me your mail address? I think the one in your
posting is a spam stopper.


Cheers,
Torsten.
 
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
Running an Executable Before Executable JAR Jason Cavett Java 8 05-16-2007 07:14 PM
what is fast dynamically linked executable or statically linked executable ?how to decide? pratap C Programming 20 03-07-2007 04:46 AM
How can I run a c executable in pwd ,while the executable is in some other directory vishsid3@gmail.com C Programming 15 08-21-2006 06:04 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
build a static python executable on linux? Alexandre Gillet Python 6 09-30-2003 04:42 PM



Advertisments