How remove Tcl/Tk fom py2exe distribution?
Thomas Heller
theller at python.net
Sat Aug 16 07:09:10 EDT 2003
"Michael Peuser" <mpeuser at web.de> writes:
>> In case I'm missing something: you could always, as part of your
>> build, just delete files from the py2exe-generated build
>> directory. For example, at the end of your setup.py script, add some
>> lines to delete the tk/tcl files from your build path. I've used
>> this "strategy" sometimes when building py2exe apps that use the
>> Python Imaging Library. (PIL has tcl/tk import dependencies, but
>> doesn't actually need tcl/tk for the majority of its functions.)
IMO --exclude Tkinter should also work.
>
> I tried this! This will not help, because - in this case - Tkinter *is*
> used. The importer just does not find it (probably because py2exe modifies
> its behaviour....
>
> This is why I use
>
> Tkinter= __import__("Tkinter")
>
> But this does not wort either...
Ok. First you should make sure that Tkinter is not found and copied by
py2exe. The '--exclude' flag could be used, or the above __import__
trick.
Then, you should make sure that your executable finds the 'standard'
Tkinter module (and tcl/tk) installation by including the proper
directory into sys.path. Normally py2exe takes some care to *not* find
modules or packages from a Python installation on the system.
A little experimentation is probably needed, and hacking py2exe could
maybe help. You can change this code (in py2exe\build_exe.py, near line
926)
header = struct.pack("<iii",
self.optimize, # optimize
0, # verbose
0x0bad3bad,
)
into this
header = struct.pack("<iii",
self.optimize, # optimize
1, # verbose
0x0bad3bad,
)
and the resulting executable will trace import statements.
Thomas
More information about the Python-list
mailing list