Single Executable File from Python script

938 views
Skip to first unread message

Python Hacker

unread,
Jun 17, 2012, 7:56:40 AM6/17/12
to cython-users
Hi guys,

I'm trying to create single executable file in Windows using Cython.

I done the following steps:

python C:\Python27\Scripts\cython.py --embed Fibonacci.py
gcc Fibonacci.c -o Fibonacci.exe -IC:\Python27\include -LC:
\Python27\libs -lpython27

Ok, my Fibonacci.exe has 84 KB size. But it isn't standalone
application! How can I get it?

Thans for your reply.

Robert Bradshaw

unread,
Jun 20, 2012, 3:32:34 AM6/20/12
to cython...@googlegroups.com
You can try passing the --static flag to gcc to link everything in
together, but you also have to worry about linking and shipping the
entire standard library (or at least everything you use). It might be
easier to ship an executable that simply contains a full python
install to run against (not that I have any experience doing this
either).

- Robert

Chris Barker

unread,
Jun 20, 2012, 12:35:48 PM6/20/12
to cython...@googlegroups.com
On Wed, Jun 20, 2012 at 12:32 AM, Robert Bradshaw <robe...@gmail.com> wrote:

>> I'm trying to create single executable file in Windows using Cython.

>> Ok, my Fibonacci.exe has 84 KB size. But it isn't standalone
>> application! How can I get it?

> You can try passing the --static flag to gcc to link everything in
> together, but you also have to worry about linking and shipping the
> entire standard library (or at least everything you use).

For something simple (like I assume Fibonacci.pyx is...) this may be
reasonable, but any "real" python program is going to require a lot if
stuff.

> It might be
> easier to ship an executable that simply contains a full python
> install to run against

That would be what py2ex, pyInstaller, py2App, bbfreeze, etc.. essentially do.

You could either:
simply use one of those, and use a python script as your front-end

or

use one of those to build a bundle of stuff you need, and hack it to
put your exe at the "front" -- bbfreee may the easiest for this
approach (it can provide a "frozen" interpreter), but I doubt there is
a point.

-Chris



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

Python Hacker

unread,
Jun 21, 2012, 7:51:34 AM6/21/12
to cython-users
Thanks for your reply.

What's about cython_freeze?
http://hg.cython.org/cython-devel/file/b816b03ff502/Demos/freeze/README.txt#l1

How can I use it on Linux and Windows machine?
Reply all
Reply to author
Forward
0 new messages