This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: _tkinter does not build on Windows 7
Type: behavior Stage: resolved
Components: Build, Windows Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder: Update PCbuild/readme.txt
View: 19273
Assigned To: Nosy List: brian.curtin, loewis, prlw1, steven.winfield, terry.reedy, tim.golden
Priority: normal Keywords:

Created on 2012-01-15 04:59 by terry.reedy, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg151276 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-01-15 04:59
Modules/_tkinter.py #includes Modules/tkinter.h, tcl.h, and tk.h. The latter two #include tclDecls.h, tclPlatDecls.h, and tkDecls.h. I obtained 8.5.9 versions of all 5 and added them to Include/. Although they came from Ubuntu, they appear to be cross-platform in that they look for Mac and Win defines. They make the corresponding build errors go away. However, one remains: a failure to open X11/Xlib.h.

This must come from the following in tk.h:
#ifndef RC_INVOKED
#ifndef _XLIB_H
#   if defined(MAC_OSX_TK)
#    include <X11/Xlib.h>
#    include <X11/X.h>
#   else
#    include <X11/Xlib.h>
#   endif
#endif
#ifdef __STDC__
#   include <stddef.h>
#endif

It seems this tk.h header, at least, expects RC_INVOKED to be defined on non-X11 platforms. Something here is crucially different than on the machine that builds Python for windows. The version of tk.h? the absence of X11/xlib.h? the pcbuild stuff? or the Visual Studio version?

I tried to compile PCbuild/pcbuild.sln with VC2008 Express in the 3.3, 3.2, and 2.7 repositories. For 3.3, I tried both debug and release builds.
msg151297 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-01-15 18:23
See PCbuild/readme.txt, and follow its instructions scrupulously. If you use a different build procedure, or different Tcl sources, you are on your own.
msg151328 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-01-16 06:37
I have read readme.txt, more than once. It seems a bit out-of-date. Parts of it I have trouble understanding, or at least, being sure I have understood. It seems to disagree with the devguide about whether to build debug or release builds. I though of opening an issue for possible readme.txt revisions.

However, my goal at the moment is to be able to test patches to IDLE .py files in repository builds on Win7, with the least fuss necessary. I have several questions:

About _tkinter, readme.txt says:
"Wraps the Tk windowing system.  Unlike _sqlite3, there's no    corresponding tcltk.vcproj-type project that builds Tcl/Tk from    vcproj's within our pcbuild.sln, which means this module expects to find a pre-built Tcl/Tk in either ..\..\tcltk for 32-bit or   ..\..\tcltk64 for 64-bit (relative to this directory).  See below for instructions to build Tcl/Tk."

I interpret 'this module expects to find' to mean 'after _tkinter is 
built'. If building _tkinter requires tcltk first, it should says so. (And I did try to build it, see below.)

I interpret 'this directory' to mean, on my system, '.../dev/cpython/pcbuild'. I therefore interpret '../../tcltk' to mean '.../dev/tcltk'. Experiments in Command Prompt support this.

I interpret 'pre-built Tcl/Tk' to include the pre-built Tcl/Tk already installed on my system, just as it does on *nix. I tried copying the contents of /tcl and dlls/t*.pyd from installed 3.2.2 into dev/tcltk, but that does not work. Is there any way to use the existing tcl/tk build?

As for rebuilding, the readme says "run either external.bat or 
external-amd64.bat in the ..\Tools\buildbot directory from ..\, i.e.:

    C:\..\svn.python.org\projects\python\trunk\PCbuild>cd ..
    C:\..\svn.python.org\projects\python\trunk>Tools\buildbot\external.bat"

That exact file builds 8.5.2 instead of 8.5.9, so the above could be updated to refer to the current hg version: 'whatever/cpython> Tools...'.

external.bat runs external-common.bat. That brings all the external dependencies, which is more than I need or really want. Can I comment out the other dependencies if I want?

In any case, the file has near the top '''
@rem XXX: If you need to force the buildbots to start from a fresh environment, uncomment
@rem the following, check it in, then check it out, comment it out, then check it back in.
@rem if exist tcltk rd /s/q tcltk
@rem if exist tcltk64 rd /s/q tcltk64
'''
I do not really understand this. Does 'rd' mean 'remove directory? Can I just remove the tcltk directory I made and ignore this?

Each dependency has a line like
"   svn export http://svn.python.org/projects/external/tcl-8.5.9.0"
Can I use hg export or do I need to find and install (tortoise)svn?
Are the svn urls still correct or is there an hg equivalent?
msg159324 - (view) Author: Steven Winfield (steven.winfield) Date: 2012-04-25 17:31
The tk sources (at least the 8.5.11 version I'm looking at now) have some X11 headers that can be used by the windows build in the "xlib" directory.
msg201275 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-10-25 18:31
I got sufficient answers on core-mentorship list to build and run.
#19273 revised and updated readme.txt.
History
Date User Action Args
2022-04-11 14:57:25adminsetgithub: 57998
2013-10-25 18:31:01terry.reedysetstatus: open -> closed
superseder: Update PCbuild/readme.txt
messages: + msg201275

resolution: out of date
stage: resolved
2012-08-20 14:53:05prlw1setnosy: + prlw1
2012-04-25 17:31:05steven.winfieldsetnosy: + steven.winfield
messages: + msg159324
2012-01-16 06:37:57terry.reedysetmessages: + msg151328
2012-01-15 18:23:22loewissetmessages: + msg151297
2012-01-15 04:59:15terry.reedycreate