I had a look a Ned’s comments in bpo-34956[4] and related commits; IIUC, trying to use the macOS bundled Tcl/Tk is not recommended, so why then do we try so hard (in setup.py) to locate it? How about simplifying it to this:
Replace TCLTK_INCLUDES with TCLTK_CFLAGS (for consistency)
Keep the --with-tcltk-* options
In configure:
use pkgconfig to check for Tcl/Tk >= 8.4.2 (we’ll have to loop over the various namings here: tcl, tcl8.6, tcl84, etc.)
fall back to standard AC check headers/libs
Reduce detect_tkinter in setup.py to one addext() line
pkgconfig should cover most *nix systems. Mac users should use Homebrew::
Would the build continue to work without having pkg-config? The tool is not installed on macOS by default or through Xcode / Command Line Tools. Not everyone uses homebrew or macports.
I guess installing pkg-config isn’t too bad, one already has to install other libraries to get a full build (such as openssl).
BTW. I’m in favour of dropping support for the system install of Tcl/Tk, that library is ancient and broken. It is better to not have tkinter than one using the system version of Tk.
What’s the status of this for Python 3.11? I’ve been trying to test 3.11 from git w/TclTk but I can’t seem to reliably build locally with Brew installed packages.