Two exe's in one py2exe dist?

Hi Jean Michel,

Doing this requires a lot of overhead, and it is difficult if both
exe's have to share a common data structure. If you convert console.py
in a console exe, the dist dir is 10Mb big to start with. Then if I
convert the gui.py in a exe I get another 25 Mb. So if the user
installs both versions it will be 35 Mb worth of data on his PC. Which
is a bit too much..

I did find a very elegant method though. In the setup script, simply
define both a windows parameter and a console parameter. py2exe
converts both start scripts to an exe, and the library.zip will
contain all the files needed by both scripts. It couldn't be more
elegant then that :wink:

setup( windows = [ { "script": "cvlgui.pyw",
                     "icon_resources": [(1, "cvlgui.ico")],
                     "other_resources": [(24,1,manifest)] } ]
      ,data_files=["dll\\msvcp71.dll"],
      console = [ "cvl.py" ]
    )

Regards,
- Jorgen

···

On Feb 10, 2008 5:21 PM, jmf <jfauth@bluewin.ch> wrote:

Hi all,

Surprisingly, this quite easy to do. I have done this several times on my
w2k box.

The trick:
py2exe will create a bootstrap (exe) from the application scripts. It
"transforms" the *main* script and only the main into the exe and sets
all the application dependencies (Python scripts) in the library.zip. The
library.zip contains everything, except the main/start script.

My recipe:
For a given application called app, create two start scripts, eg, one called
appgui.py (appgui.pyw) and the other called appconsole.py.

For each version, appgui/appconsole, create a setup for py2exe and build
the dist in different directories.

One this is done, one has

in ..\distgui : appgui.exe, library.zip, wx*.dll, python.dll,icon, help files...
Library.zip hold everything but appgui.py.

in ..\distconsole : appconsole.exe, library.zip, ....
Library.zip hold everything but appconsole.py.

Move appconsole.exe into ..\distgui.
Done!

Jean-Michel Fauth, Switzerland

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Once again,

Thanks everybody! I got it to work the way I said, by simply
specifying the console and windows parameter in the same setup
function. I was wrestling with "module os not found" errors only to
figure out that one of the code paths that would only be executed when
compiled with py2exe, used the not yet imported OS module :wink: I can
finally round up all chores and one of these days announce the app.

- Jorgen

···

On Feb 11, 2008 9:53 PM, Robin Dunn <robin@alldunn.com> wrote:

Jorgen Bodde wrote:
> Hi Jean Michel,
>
> Doing this requires a lot of overhead, and it is difficult if both
> exe's have to share a common data structure. If you convert console.py
> in a console exe, the dist dir is 10Mb big to start with. Then if I
> convert the gui.py in a exe I get another 25 Mb. So if the user
> installs both versions it will be 35 Mb worth of data on his PC. Which
> is a bit too much..
>
> I did find a very elegant method though. In the setup script, simply
> define both a windows parameter and a console parameter. py2exe
> converts both start scripts to an exe, and the library.zip will
> contain all the files needed by both scripts. It couldn't be more
> elegant then that :wink:

And if you have more than one gui app or more than one console app then
I think you can just add more entries to the appropriate list as needed.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org