473,785 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How remove Tcl/Tk fom py2exe distribution?

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__("Tki nter")

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
Jul 18 '05 #1
5 7088
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
Jul 18 '05 #2
Hi Graham - thnak you for your answer!

"Graham Fawcett" <fa*****@teksav vy.com> schrieb im Newsbeitrag
news:ma******** *************** ***********@pyt hon.org...
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__("Tki nter")

But this does not wort either...

Kindly Michael P

Jul 18 '05 #3
"Michael Peuser" <mp*****@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__("Tki nter")

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_ex e.py, near line
926)
header = struct.pack("<i ii",
self.optimize, # optimize
0, # verbose
0x0bad3bad,
)
into this
header = struct.pack("<i ii",
self.optimize, # optimize
1, # verbose
0x0bad3bad,
)
and the resulting executable will trace import statements.

Thomas
Jul 18 '05 #4
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" <th*****@python .net> schrieb im Newsbeitrag
news:7k******** **@python.net.. .

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_ex e.py, near line
926)
header = struct.pack("<i ii",
self.optimize, # optimize
0, # verbose
0x0bad3bad,
)
into this
header = struct.pack("<i ii",
self.optimize, # optimize
1, # verbose
0x0bad3bad,
)
and the resulting executable will trace import statements.

Thomas

Jul 18 '05 #5

"Michael Peuser" <mp*****@web.de > schrieb im Newsbeitrag
news:bh******** *****@news.t-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
CheckPythonPath s from regcheck.py
Kindly
Michael P
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
3701
by: Thomas Heller | last post by:
I'm currently working on a new version of py2exe, which will require Python 2.3 and later, because it uses the zipimport mechanism. Since py2exe is a distutils extension, and since C compilers are commonly available on most platforms except Windows, it would be fairly easy to let py2exe generate a C source file installing this import hook, and let distutils' C compiler build an executable file from this. Would this be useful, or would...
1
2593
by: Funduk | last post by:
Hello, So I've been playing with Python and Pygame for a while and I decided I wanted to make a real executable so I could send that stuff over to my friends to show off my <sarcasm>maad skillz</sarcasm>. Everything was going great I went and got all the newest software (including Distutils and PY2EXE) and read the docs on making a setup py.
0
1532
by: Jimmy Retzlaff | last post by:
py2exe 0.6.4 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.4:
0
1518
by: Jimmy Retzlaff | last post by:
py2exe 0.6.5 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.5:
0
1729
by: Jimmy Retzlaff | last post by:
py2exe 0.6.6 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.6:
2
2410
by: Marcus | last post by:
Hi, I'm to the stage where I need to deploy the app I built with wxPython. I've been able to successfully build it w/py2exe into a binary (about 10MB size in total). What I'd like to do is create an automatic updater, so that I can have users download updated versions of my *application code* without having to have them redownload everything (the interpreter, etc) via a complete redownload (I want to package some things as...
1
2991
by: Jimmy Retzlaff | last post by:
py2exe 0.6.8 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.8:
0
1529
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
0
3123
by: Jimmy Retzlaff | last post by:
py2exe 0.6.9 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.9:
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.