How to create a single executable console application?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Podi

    #1

    How to create a single executable console application?

    I followed the instructions from


    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

    #2
    Re: How to create a single executable console application?

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

    Cheers!

    The mcillian installer development is discontinued.

    mirror:


    Continued development(not tested yet):


    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.p y
    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).

    Comment

    • Podi

      #3
      Re: How to create a single executable console application?

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

      Cheers!

      The mcillian installer development is discontinued.

      mirror:


      Continued development(not tested yet):


      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.p y
      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).

      Comment

      Working...