How to create a single executable console application?

P

Podi

I followed the instructions from
http://starship.python.net/crew/theller/moin.cgi/SingleFileExecutable

Copied the second setup.nsi, setup.py, single.py and everything works
like a
champ.

I then replaced "single.exe" by "hello.exe" in setup.nsi. Created
hello.py as
follows:

#! python
def main():
print 'Hello world'

if __name__ == '__main__':
main()
#End of file

And changed setup.py as follows:

#! python
from distutils.core import setup
import py2exe
sys.argv.append('py2exe')

setup( console=["hello.py"] )
# End of file

After running python setup.py, dist\hello.exe was created and it runs
fine
("Hello world" printed on the console).

Compiled setup.nsi, and hello.exe was created in current directory.
However,
when executed, nothing was printed.

I might just missed something obvious. Can anyone help me?

Has anyone built a single executable for console application? Please
post your .nsi file.

Thanks very much,
P
 
P

Podi

Alright, pythoneers, here is what I have found from
http://wiki.wxpython.org/index.cgi/CreatingStandaloneExecutables. This
is much easier than the py2exe + nullsoft combo :)

Cheers!

The mcillian installer development is discontinued.

mirror:
http://davidf.sjsoft.com/mirrors/mcmillan-inc/installer_dnld.html

Continued development(not tested yet):
http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi

This works on Win32.
Unzip the Installer in a directory of your choice, and cd there.

Configure the Installer by running:

python Configure.py

Python must be in your PATH for this to work, if it's not, type from
the command prompt: PATH=%PATH%;c:\python23

where c:\python23 must be replaced with the root of your python
installation.
Then, assuming the source code is app.py (placed in c:\source): python
Makespec.py --upx --onefile --noconsole c:\source\app.py
python Build.py app\app.spec

Replace 'app' everywhere above with your application name.
You will end up with app\app.exe under the Installer dir.This is a one
file .exe containing all the application.
If you don't want a one-file build, suppress the option --onefile
above.
If you don't have upx installed (or don't want to use it), suppress the
option --upx above.
The option --noconsole is needed to produce a windows gui application,
instead of a console one (so the command shell won't pop up when you
run the application).
 
P

Podi

Alright, pythoneers, here is what I have found from
http://wiki.wxpython.org/index.cgi/CreatingStandaloneExecutables. This
is much easier than the py2exe + nullsoft combo :)

Cheers!

The mcillian installer development is discontinued.

mirror:
http://davidf.sjsoft.com/mirrors/mcmillan-inc/installer_dnld.html

Continued development(not tested yet):
http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi

This works on Win32.
Unzip the Installer in a directory of your choice, and cd there.

Configure the Installer by running:

python Configure.py

Python must be in your PATH for this to work, if it's not, type from
the command prompt: PATH=%PATH%;c:\python23

where c:\python23 must be replaced with the root of your python
installation.
Then, assuming the source code is app.py (placed in c:\source): python
Makespec.py --upx --onefile --noconsole c:\source\app.py
python Build.py app\app.spec

Replace 'app' everywhere above with your application name.
You will end up with app\app.exe under the Installer dir.This is a one
file .exe containing all the application.
If you don't want a one-file build, suppress the option --onefile
above.
If you don't have upx installed (or don't want to use it), suppress the
option --upx above.
The option --noconsole is needed to produce a windows gui application,
instead of a console one (so the command shell won't pop up when you
run the application).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top