TL;DR: simplify Tcl/Tk detection to pkgconfig and basic autoconf headers/libs checks.
Background
@tiran and I have been rewriting stdlib extension module dependency detection in bpo-45847 and bpo-45573, partly sparked by Christian’s bpo-45743.
Proposal
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:
- 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::
$ 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
3 Likes
nad
(Ned Deily)
2
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.
2 Likes
Even better. I’ve got a WIP branch from a couple of months ago. I’ll dig it up and create a PR.
storchaka
(Serhiy Storchaka)
5
We can drop support of 8.4, and maybe even 8.5.
2 Likes
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.
tiran
(Christian Heimes)
8
You will be able to build Python without pkg-config, but some dependencies won’t be detected.
2 Likes
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.
3 Likes
Great; I’ll keep the PR as it is, then.
2 Likes
FTR, I’m talking about GH-31698
storchaka
(Serhiy Storchaka)
12
2 Likes
barry
(Barry Warsaw)
13
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
2 Likes