pythonxcodemacoscpythontcltk

MacOS source code build, Python 3.11, missing _tkinter support


I'm attempting to build Python 3.11 from source on MacOS Ventura. The build misses the _tkinter module, which I need.

I've compiled my own build of Tcl/Tk 8.6 from source, with Aqua enabled. It is installed in /Library/Frameworks/Tcl.framework and Tk.framework respectively.

I've set the TCLTK_CFLAGS and TCLTK_LIBS environment variables (show below in the configure output).

When I run the configure script, the result is missing _tkinter support. config.log shows the following

configure:13714: gcc -o conftest   -I/Library/Frameworks/Tcl.framework/Headers/ -I/Library/Frameworks/Tcl.framework/Headers/  conftest.c -L/Library/Frameworks/Tcl.framework/ -ltclstub8.6 -L/Library/Frameworks/Tk.framework/ -ltkstub8.6  >&5
In file included from conftest.c:120:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/tk.h:31:3: error: Tk 8.5 must be compiled with tcl.h from Tcl 8.5
#       error Tk 8.5 must be compiled with tcl.h from Tcl 8.5

So the issue the configure script is looking at the Xcode CLT for some reason, and not the new source build in /Library/Frameworks.

Is there a way to get the configure script to look directly at my TclTk build?

I tried building and installing Tcl and Tk 8.6 from source, and expected Python's configure script to use them through the TCLTK_CFLAGS and TCLTK_LIBS environment variables.


Solution

  • The problem was that I set TCLTK_CFLAGS='-I/Library/Frameworks/Tcl.framework/Headers/ -I/Library/Frameworks/Tcl.framework/Headers/'

    I didn't include the Tk includes e.g. TCLTK_CFLAGS='-I/Library/Frameworks/Tcl.framework/Headers/ -I/Library/Frameworks/Tk.framework/Headers/'.

    Rookie mistake. After also setting TCLTK_LIBS='-L/Library/Frameworks/Tcl.framework/ -lTcl -L/Library/Frameworks/Tk.framework/ -lTk' this configuure step completed just fine.