Mailing List Archive

Freezing an App
Hi Folks,

Sorry to ask what must be a fairly frequently asked question by now, but I
am having problems freezing an app.

It uses Tkinter and win32all (the win32api and win32con modules
spcifically). I did a freeze on it this morning, and took it into my client
site, and after about 3 hours of bashing away at the situation, I managed to
get part of the app to work properly.

The part I am having problems with is using win32api. It runs, doesnt set
the registry values it is suppoed to, and exits without giving any errors.

Could some kind soul please email me (or reply to group is fine)
step-by-step instructions for freezing a win32api program. Ideally also
telling me how I can freeze the tkinter part wqithout needing the init.tcl,
tk.tcl, and component .tcl files (like button.tcl). I am not a c/c++
programmer, so working in VC++ 5.0 is VERY strange to me, although I can
probably follow instructions. I'm not a total dummy, but when it comes to
having to build python + tkinter + win32all for windows I feel like it. I
had less problems building things for linux after using it for 3 hours.

THanks in advance for whatever help you can give me,

Calishar

P.s. My E-mail address is munged to mess up spam machines, the fix should
be obvious.
Freezing an App [ In reply to ]
Calishar wrote in message ...

> The part I am having problems with is using win32api. It runs, doesnt set
>the registry values it is suppoed to, and exits without giving any errors.

Im not sure what you mean here.

Firstly, you could consider simply shipping win32api.pyd - ie, dont freeze
it. You should definately try to get your frozen application working with
win32api.pyd before attempting to freeze it.

You do this simply by excluding win32api from the freeze using "-x win32api"

If you want to freeze the win32api sources into your app, the process then
is:
* Download the sources to the win32api module.
* Check out the .ini file that comes with freeze. It is used to locate the
source to win32apimodule.cpp.

Run freeze - it may complain it cant find the file. If so, ensure the
environment variable it uses is set. I can't recall exactly what that is.

This could do with more work - Im happy to discuss ways you can help to make
this better for the next person :-)

Mark.
Freezing an App [ In reply to ]
> > The part I am having problems with is using win32api. It runs, doesnt
set
> >the registry values it is suppoed to, and exits without giving any
errors.
>
> Im not sure what you mean here.

okay, basically I am using Python to automate a process at a client site. in
this application, I have about 4 different functions which each get called
by button clicks. One of the routines is supposed to set a registry key
based on an environment variable. The lines follow:


the_key=win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE,"Software\Stac\Rea
chout\8.0")
win32api.RegSetValueEx(the_key,"Computer Name",0,win32con.REG_SZ,mac_name)

At the moment, this is the only part of the application I dont have working
on my non-development system, unfortunately it happens to be kind of
important.

> Firstly, you could consider simply shipping win32api.pyd - ie, dont freeze

This was my first thought, I made sure that I had the .pyd file in the
same directory as the program I am running. It doesnt do it.

> You do this simply by excluding win32api from the freeze using "-x
win32api"

Tried doing this, then copying the files needed over to my '95 test system
(not the same OS,but should be close enough for this part) and when I ran
it, it crashed at line 3 of the code (import win32api)

> If you want to freeze the win32api sources into your app, the process then
> is:
> * Download the sources to the win32api module.
> * Check out the .ini file that comes with freeze. It is used to locate
the
> source to win32apimodule.cpp.
>
> Run freeze - it may complain it cant find the file. If so, ensure the
> environment variable it uses is set. I can't recall exactly what that is.

Okay, then I did this section, and when I ran freeze at the end it said:

generating table of frozen modules
No definition of module _tkinter in any specified map file.
No definition of module win32api in any specified map file.
Warning: unknown modules remain: _tkinter win32api

Which looks the same as what I had the first time. I did notice that for
win32api it was using the win32api.pyd file rather than the source code
specified in the .ini file.

> This could do with more work - Im happy to discuss ways you can help to
make
> this better for the next person :-)

Thanks for the help, I'm really starting to feel like a dummy here.

Here is the command line I am using for freeze

python freeze.py -p e:\src\python1.5.2c1 -o e:\bins e:\ghostit.py

Calishar
Freezing an App [ In reply to ]
Calishar wrote in message ...
>okay, basically I am using Python to automate a process at a client site.
in
>this application, I have about 4 different functions which each get called
>by button clicks. One of the routines is supposed to set a registry key
>based on an environment variable. The lines follow:
>
>
>the_key=win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE,"Software\Stac\Re
a
>chout\8.0")
> win32api.RegSetValueEx(the_key,"Computer
Name",0,win32con.REG_SZ,mac_name)
>
>At the moment, this is the only part of the application I dont have working
>on my non-development system, unfortunately it happens to be kind of
>important.

Are you sure the code is being executed at all? I cant imagine how these
could silently do nothing.

> This was my first thought, I made sure that I had the .pyd file in the
>same directory as the program I am running. It doesnt do it.

Why not? I would bet its not on the sys.path. Just before the import, add
a "print sys.path". Frozen programs can use .pyd files fine.

> Tried doing this, then copying the files needed over to my '95 test
system
>(not the same OS,but should be close enough for this part) and when I ran
>it, it crashed at line 3 of the code (import win32api)

Im sure that it is just path fiddling. (OK - I hope it is :-)

>generating table of frozen modules
>No definition of module _tkinter in any specified map file.
>No definition of module win32api in any specified map file.
>Warning: unknown modules remain: _tkinter win32api

OK - the .ini file may not have an entry for win32api. Im afraid I havent
use the latest version of freeze, and cant recall exactly what is in it, but
basically you need to have freeze find a [win32api] section in one of the
.ini files.

Mark.
Freezing an App [ In reply to ]
Mark Hammond <MHammond@skippinet.com.au> wrote in message
news:7f3v96$g88$1@m2.c2.telstra-mm.net.au...
> Are you sure the code is being executed at all? I cant imagine how these
> could silently do nothing.


Actually, I must plead guilty to a week long case of brain death. I took a
close look at teh code and the registry today, and the code was doing
exactly what I told it to do, which of course was not quite what I wanted it
to. I was placing the Computer Name value one level too deep.

So the program worked, the freeze worked, the programmer should be fired.

Hanging his head in shame,

Calishar