How remove Tcl/Tk fom py2exe distribution?

Discussion in 'Python' started by Michael Peuser, Aug 15, 2003.

  1. 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
    Michael Peuser, Aug 15, 2003
    #1
    1. Advertising

  2. 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
    Graham Fawcett, Aug 16, 2003
    #2
    1. Advertising

  3. Hi Graham - thnak you for your answer!

    "Graham Fawcett" <> schrieb im Newsbeitrag
    news:...
    > 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
    >
    Michael Peuser, Aug 16, 2003
    #3
  4. "Michael Peuser" <> 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
    Thomas Heller, Aug 16, 2003
    #4
  5. 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" <> schrieb im Newsbeitrag
    news:...


    > 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
    Michael Peuser, Aug 16, 2003
    #5
  6. "Michael Peuser" <> schrieb im Newsbeitrag
    news:bhl73o$745$07$-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
    Michael Peuser, Aug 16, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?=

    Posting a file directly fom a data base to the browser

    =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?=, Nov 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    289
    =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?=
    Nov 27, 2003
  2. =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?=

    Posting a file directly fom a data base to the browser

    =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?=, Nov 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    278
    =?iso-8859-1?Q?Leandro_Lacerda_Guimar=E3es?=
    Nov 27, 2003
  3. Jockser
    Replies:
    2
    Views:
    68
    Jockser
    Jun 30, 2006
  4. Mumia W.

    Inline::Tcl vs. Inline::Tcl

    Mumia W., Aug 23, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    131
    Mumia W.
    Aug 23, 2006
  5. Andrew Poulos

    get image filename fom div

    Andrew Poulos, Jul 10, 2005, in forum: Javascript
    Replies:
    8
    Views:
    129
Loading...

Share This Page