471,616 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

building exe from script

Hello,

Is there any solution for building exe file from python script
something like bbfreeze.When user write some script in
my program, it must compile script into exe without opening console
( cmd ).I'am working on Windows XP SP2 and Python 2.5.

Regards,
Vedran

Aug 20 '07 #1
2 1825
you can embed py2exe in your program.
On 8/20/07, ve***********@v-programs.com <ve***********@v-programs.comwrote:
Hello,

Is there any solution for building exe file from python script
something like bbfreeze.When user write some script in
my program, it must compile script into exe without opening console
( cmd ).I'am working on Windows XP SP2 and Python 2.5.

Regards,
Vedran

--
http://mail.python.org/mailman/listinfo/python-list

--
Furkan Kuru
Aug 20 '07 #2
nih
A bit more information is clearly needed...

1. Create a file called py2exeSetup.py with the following contents:

from distutils.core import setup
import py2exe

def compile(appName, console=False):
OPTIONS = {"py2exe": {"compressed": 1, "optimize": 0, "bundle_files":
1, } }
ZIPFILE = None

if console:
setup(
options=OPTIONS,
zipfile=ZIPFILE,
console=[appName]
)
else:
setup(
options=OPTIONS,
zipfile=ZIPFILE,
windows=[appName]
)
2. Create another file called setup.py with the following contents

import py2exeSetup

# to stop a wxPython program from loading a console window you just need to
change the
# file extension from .py to .pyw

# change Filename to your XXXApp.pyw filename
# change to py2exeSetup.compile('Filename.pyw', console=True) to show the
console
py2exeSetup.compile('Filename.pyw')
3. Create a file called Compile.bat with the following contents

REM change Filename to your XXXApp.exe filename
REM make sure that python is in your system path

python setup.py py2exe
copy dist\Filename.exe Filename.exe
if errorlevel 1 pause
4. Put all these files in the same place as the program you want to convert
to exe and run Compile.bat
an *.exe file will now be in the same folder as your python files :)

I have py2exeSetup.py in a separate 'Shared' folder so there is only one
copy of it,
so all my programs only have setup.py and compile.bat in them
btw if you have a load of programs that you want to compile in one go the
add a file CompileAll.bat
in the root folder that all the programs are in, with the following
contents:

cd "ProgramOne"
call py2exe.bat
cd..

cd "ProgramTwo"
call py2exe.bat
cd..

# REM this part will execute if all programs compiled & copied ok
echo all copied ok!
pause
I know hardly anything about ms-dos, but this works ok:/

gl!

<ve***********@v-programs.comwrote in message
news:11*********************@r29g2000hsg.googlegro ups.com...
Hello,

Is there any solution for building exe file from python script
something like bbfreeze.When user write some script in
my program, it must compile script into exe without opening console
( cmd ).I'am working on Windows XP SP2 and Python 2.5.

Regards,
Vedran

Aug 20 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kylotan | last post: by
1 post views Thread by Ed | last post: by
7 posts views Thread by Christopher Benson-Manica | last post: by
15 posts views Thread by kyosohma | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

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.