TL;DR: simplify Tcl/Tk detection to
pkgconfig and basic
autoconf headers/libs checks.
@tiran and I have been rewriting stdlib extension module dependency detection in bpo-45847 and bpo-45573, partly sparked by Christian’s bpo-45743.
I had a look a Ned’s comments in bpo-34956 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:
TCLTK_CFLAGS (for consistency)
- Keep the
- 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
setup.py to one
pkgconfig should cover most *nix systems. Mac users should use Homebrew::
$ PKG_CONFIG_PATH=$(brew --prefix tcl-tk)/lib/pkgconfig pkg-config --cflags --libs tcl tk
-I/usr/local/Cellar/tcl-tk/8.6.12_1/include -L/usr/local/Cellar/tcl-tk/8.6.12_1/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6
Thoughts? cc. @nad, @ronaldoussoren
We should deprecate the TCLTK_* variables and just rely on pkg-config. That works with MacPorts as well. Write up a PR and we can review it there.
Even better. I’ve got a WIP branch from a couple of months ago. I’ll dig it up and create a PR.
We can drop support of 8.4, and maybe even 8.5.
Nice! I’ll create a separate bpo for that, though.
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.
You will be able to build Python without pkg-config, but some dependencies won’t be detected.
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.
Great; I’ll keep the PR as it is, then.
FTR, I’m talking about GH-31698
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.
GH-31698 was merged;
configure now uses pkg-config to find Tcl/Tk.
The devguide was updated with new build instructions (earlier today). You can use this to build with Homebrew supplied Tcl/Tk:
$ PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" ./configure