How to create a single executable console application?

Discussion in 'Python' started by Podi, Apr 10, 2006.

  1. Podi

    Podi Guest

    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
     
    Podi, Apr 10, 2006
    #1
    1. Advertising

  2. Podi

    Podi Guest

    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).
     
    Podi, Apr 14, 2006
    #2
    1. Advertising

  3. Podi

    Podi Guest

    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).
     
    Podi, Apr 14, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piet
    Replies:
    2
    Views:
    342
  2. Replies:
    15
    Views:
    510
    Dave Thompson
    Aug 21, 2006
  3. pratap
    Replies:
    20
    Views:
    785
    Flash Gordon
    Mar 7, 2007
  4. NicolasG
    Replies:
    11
    Views:
    1,933
    Gabriel Genellina
    Jul 26, 2007
  5. Replies:
    0
    Views:
    460
Loading...

Share This Page