Sorry this is not exactly a wxPython question - I am hoping one of the
Windows folks here knows the answer anyway.
We're finally porting our code to Windows, and it mostly works but
right now it needs to be launched from the command line or a .bat file
which starts Python. Because the entire distribution is huge (1.8GB)
and does not use the standard Python module installation method,
bundling the entire thing into a .exe file appears to be hopeless. I
would like to get around this by creating a simple iconified launcher
that calls one of the .bat files and exits. On Mac I was able to do
this by using py2app to bundle a stub program like so (the target
script on Mac is actually a shell script, of course:
import os
os.environ["PYTHONPATH"] = ""
os.spawnv(os.P_NOWAIT, '/path/to/launcher', ["MyApp"])
This works well, although it's a little sluggish starting up. I
expected to be able to do the same on Windows with py2exe. In fact,
while I can indeed generate the launcher executable, it only opens a
cmd.exe window and sits there. I could start it successfully from the
command line, although now that isn't even working. Since I never use
Windows I am completely at a loss and Googling has not turned up
anything. Is what I'm attempting even possible, and is there a better
way to do this?
Sorry this is not exactly a wxPython question - I am hoping one of the
Windows folks here knows the answer anyway.
We're finally porting our code to Windows, and it mostly works but
right now it needs to be launched from the command line or a .bat file
which starts Python. Because the entire distribution is huge (1.8GB)
and does not use the standard Python module installation method,
bundling the entire thing into a .exe file appears to be hopeless. I
would like to get around this by creating a simple iconified launcher
that calls one of the .bat files and exits. On Mac I was able to do
this by using py2app to bundle a stub program like so (the target
script on Mac is actually a shell script, of course:
import os
os.environ["PYTHONPATH"] = ""
os.spawnv(os.P_NOWAIT, '/path/to/launcher', ["MyApp"])
This works well, although it's a little sluggish starting up. I
expected to be able to do the same on Windows with py2exe. In fact,
while I can indeed generate the launcher executable, it only opens a
cmd.exe window and sits there. I could start it successfully from the
command line, although now that isn't even working. Since I never use
Windows I am completely at a loss and Googling has not turned up
anything. Is what I'm attempting even possible, and is there a better
way to do this?
thanks,
Nat
···
On 2/27/12 1:58 PM, Nat Echols wrote:
--
Robin Dunn
Software Craftsman
Why not simply have an icon that points to a .pyw file that runs your
code, if python is installed correctly then double clicking a .pyw file,
or a shortcut to it will launch python with that initial script and no
console window.
Gadget/Steve
···
On 27/02/2012 9:58 PM, Nat Echols wrote:
Sorry this is not exactly a wxPython question - I am hoping one of the
Windows folks here knows the answer anyway.
We're finally porting our code to Windows, and it mostly works but
right now it needs to be launched from the command line or a .bat file
which starts Python. Because the entire distribution is huge (1.8GB)
and does not use the standard Python module installation method,
bundling the entire thing into a .exe file appears to be hopeless. I
would like to get around this by creating a simple iconified launcher
that calls one of the .bat files and exits. On Mac I was able to do
this by using py2app to bundle a stub program like so (the target
script on Mac is actually a shell script, of course:
import os
os.environ["PYTHONPATH"] = ""
os.spawnv(os.P_NOWAIT, '/path/to/launcher', ["MyApp"])
This works well, although it's a little sluggish starting up. I
expected to be able to do the same on Windows with py2exe. In fact,
while I can indeed generate the launcher executable, it only opens a
cmd.exe window and sits there. I could start it successfully from the
command line, although now that isn't even working. Since I never use
Windows I am completely at a loss and Googling has not turned up
anything. Is what I'm attempting even possible, and is there a better
way to do this?
What is in the batch file besides just launching Python with your main script? If nothing then I would just run "pythonw.exe args mainscriptname.py" from your stub instead of using the batch file. That will help you avoid the extra console window and probably make some other things simpler too. If you need to set some environment variables or something before starting up the real application then the stub can also do that before launching the real application.
Another approach that may be a bit cleaner and better is to have your stub import and run your main script, but exclude it (and its dependencies) from bundling by py2exe. That will save you the extra time of spawning a new python process.
···
On 2/27/12 1:58 PM, Nat Echols wrote:
Sorry this is not exactly a wxPython question - I am hoping one of the
Windows folks here knows the answer anyway.
We're finally porting our code to Windows, and it mostly works but
right now it needs to be launched from the command line or a .bat file
which starts Python. Because the entire distribution is huge (1.8GB)
and does not use the standard Python module installation method,
bundling the entire thing into a .exe file appears to be hopeless. I
would like to get around this by creating a simple iconified launcher
that calls one of the .bat files and exits. On Mac I was able to do
this by using py2app to bundle a stub program like so (the target
script on Mac is actually a shell script, of course:
import os
os.environ["PYTHONPATH"] = ""
os.spawnv(os.P_NOWAIT, '/path/to/launcher', ["MyApp"])
This works well, although it's a little sluggish starting up. I
expected to be able to do the same on Windows with py2exe. In fact,
while I can indeed generate the launcher executable, it only opens a
cmd.exe window and sits there. I could start it successfully from the
command line, although now that isn't even working. Since I never use
Windows I am completely at a loss and Googling has not turned up
anything. Is what I'm attempting even possible, and is there a better
way to do this?
What is in the batch file besides just launching Python with your main
script? If nothing then I would just run "pythonw.exe args
mainscriptname.py" from your stub instead of using the batch file. That
will help you avoid the extra console window and probably make some other
things simpler too. If you need to set some environment variables or
something before starting up the real application then the stub can also do
that before launching the real application.
Yes, we need to set several environment variables, including
PYTHONPATH (about 25 extra paths required). I will try using a Python
stub instead, thanks.
Another approach that may be a bit cleaner and better is to have your stub
import and run your main script, but exclude it (and its dependencies) from
bundling by py2exe. That will save you the extra time of spawning a new
python process.
That would be even better - unfortunately, this appears to end up
excluding many dependencies of our code as well.
-Nat
···
On Mon, Feb 27, 2012 at 2:27 PM, Robin Dunn <robin@alldunn.com> wrote:
Okay, that appears to work - I'd much rather use a real scripting
language anyway. While I'm on the subject of Windows, is there a way
to switch to my own icon instead of the Python logo on the program
button in the task bar? wx.TaskBarIcon() sets the little icon next to
the status symbols, which isn't what I wanted.
thanks,
Nat
···
On Mon, Feb 27, 2012 at 2:27 PM, Robin Dunn <robin@alldunn.com> wrote:
What is in the batch file besides just launching Python with your main
script? If nothing then I would just run "pythonw.exe args
mainscriptname.py" from your stub instead of using the batch file. That
will help you avoid the extra console window and probably make some other
things simpler too. If you need to set some environment variables or
something before starting up the real application then the stub can also do
that before launching the real application.