Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How remove Tcl/Tk fom py2exe distribution?

Reply
Thread Tools

How remove Tcl/Tk fom py2exe distribution?

 
 
Michael Peuser
Guest
Posts: n/a
 
      08-15-2003
Hi,
I should like to make a distribution (using Tkinter), with standard DLLs
removed.

pythonXX.dll is no problem.

tcl und tk, which make the mass of mega bytes, cannot be removed because
_tkinter.pyd seems to expect them in the same directory

(Question 1) Is there a configration or path setting in py2exe/distutils I
have overlooked?

O.k. In fact I do not want to have _tkinter.dll either because it belongs to
standard distribution
The command line option --exclude Tkinter however leads to an error message
when running the exe - this could have been expected however

Now I changed
import Tkinter
to
Tkinter= __import__("Tkinter")

This worked fine sofar as --exclude Tkinter was no longer needed to prevent
py2exe from copying tcl/tk

However "Tkinter" was not found by imputils now...

(Question 2) What did I miss??

Kindly
Michael P


 
Reply With Quote
 
 
 
 
Graham Fawcett
Guest
Posts: n/a
 
      08-16-2003
Michael Peuser wrote:

>Hi,
>I should like to make a distribution (using Tkinter), with standard DLLs
>removed.
>
>pythonXX.dll is no problem.
>
>tcl und tk, which make the mass of mega bytes, cannot be removed because
>_tkinter.pyd seems to expect them in the same directory
>
>(Question 1) Is there a configration or path setting in py2exe/distutils I
>have overlooked?
>
>O.k. In fact I do not want to have _tkinter.dll either because it belongs to
>standard distribution
>The command line option --exclude Tkinter however leads to an error message
>when running the exe - this could have been expected however
>
>


It's a bit unclear, Michael, what you're trying to accomplish. On the
one hand, you're using py2exe to deploy your application, which suggests
that you don't expect your users to have a Python distribution on their
computers. On the other hand, you're looking to deploy a Tkinter app,
but without any tcl/tk files, because they "belong to the standard
distribution", suggesting that you *do* expect your users to have a
Python distribution.

If you can assume that your clients have a standard distribution on
their machines, don't use py2exe. It's the wrong tool for the job.

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

-- Graham


 
Reply With Quote
 
 
 
 
Michael Peuser
Guest
Posts: n/a
 
      08-16-2003
Hi Graham - thnak you for your answer!

"Graham Fawcett" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Michael Peuser wrote:
>
> >Hi,
> >I should like to make a distribution (using Tkinter), with standard DLLs
> >removed.

[..details in first posting ...]
>
> It's a bit unclear, Michael, what you're trying to accomplish. On the
> one hand, you're using py2exe to deploy your application, which suggests
> that you don't expect your users to have a Python distribution on their
> computers. On the other hand, you're looking to deploy a Tkinter app,
> but without any tcl/tk files, because they "belong to the standard
> distribution", suggesting that you *do* expect your users to have a
> Python distribution.



It is more difficult:
I *can* request the potiential user to install a "standard" Python of a
given version, but not more! And by no means do I want to interfere with his
or her installation. This means *everything* except minimal Python
(includingTcl/Tk) must be packed somehow.....

The program shall not be *installed* but run from a double click!

Only on special request I can deliver thePython-, Tcl-, Tk- dlls and this
phantastic Tcl folder with megabytes of chinese character sets....

But I mostly want to reduce the size of the distribution, especially in
upgrade and bug-fix situations.

> 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.)
>
> -- Graham
>


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...

Kindly Michael P
>



 
Reply With Quote
 
Thomas Heller
Guest
Posts: n/a
 
      08-16-2003
"Michael Peuser" <(E-Mail Removed)> 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
 
Reply With Quote
 
Michael Peuser
Guest
Posts: n/a
 
      08-16-2003
Thank you Thomas, for these excellent advice. "verbose" of course just
supports debugging and does not prevent py2exe from beeing quite autistic.
And it does a good job in that: Not only sys.path but sys.prefix as well as
sys.exec_prefix are faked to the local directory. This makes it a little bit
harder to supplement the path info.

Tcl also has the nasty habbit to look arround according to sys.prefix
settings and trying this and that....

Nevertheless I think I can do the next step. It could be of help, if py2exe
either
- could become configurable (i.e. optionally leave the os variables as they
are)
or
- make them somewhere available

KIndly
Michael P


"Thomas Heller" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...


> 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



 
Reply With Quote
 
Michael Peuser
Guest
Posts: n/a
 
      08-16-2003

"Michael Peuser" <(E-Mail Removed)> schrieb im Newsbeitrag
news:bhl73o$745$07$(E-Mail Removed)-online.com...
> Thank you Thomas, for these excellent advice. "verbose" of course just
> supports debugging and does not prevent py2exe from beeing quite autistic.
> And it does a good job in that: Not only sys.path but sys.prefix as well

as
> sys.exec_prefix are faked to the local directory. This makes it a little

bit
> harder to supplement the path info.



Well not *as* much. Because I am using win32api anyhow, it was easy to paste
CheckPythonPaths from regcheck.py
Kindly
Michael P


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Dangers of occular diabetes fom Vista Andromedan Windows 64bit 13 10-16-2006 04:37 PM
SP2 temporarily blocks web page pictures fom downloading Treb Computer Support 6 09-06-2004 09:37 PM
Posting a file directly fom a data base to the browser =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?= ASP .Net 0 11-27-2003 07:22 PM
Posting a file directly fom a data base to the browser =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?= ASP .Net 0 11-27-2003 07:22 PM



Advertisments