From matt at mondoinfo.com Thu Dec 7 17:18:03 2023 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 7 Dec 2023 16:18:03 -0600 (CST) Subject: [Pythonmac-SIG] Trouble building tkinter for Aqua Message-ID: <1701986926.91.1871@mint-julep.mondoinfo.com> I'm trying to compile Python 3.12.0 from source on a new ARM MacBook. I haven't had any trouble except with the tkinter module. I've built Python from source any number of times before on Linux and macOS, but previously always with X11. (For the moment, I'm just doing an ordinary Unix build, not a Framework build.) I've built Tcl and Tk (with --enable-aqua) and the tests run. (Tk seems unhappy with a few of the window manager tests but they don't seem like a big deal and nothing blows up.) The libraries are in /usr/local/lib: $ ls -l /usr/local/lib/libtk8.6.dylib -r-xr-xr-x 1 root staff 1572304 Dec 6 22:50 /usr/local/lib/libtk8.6.dylib $ ls -l /usr/local/lib/libtcl8.6.dylib -r-xr-xr-x 1 root staff 1558656 Dec 6 17:58 /usr/local/lib/libtcl8.6.dylib But when I run configure, I get: checking for stdlib extension module _tkinter... missing At the bottom of configure's output, I get: configure: WARNING: pkg-config is missing. Some dependencies may not be detected correctly. So I've tried hand-hacking the Makefile, replacing: MODULE__TKINTER_STATE=missing with: MODULE__TKINTER_STATE=yes MODULE__TKINTER_CFLAGS= MODULE__TKINTER_LDFLAGS=-ltk8.6 -ltcl8.6 But then make gives me: [ERROR] _tkinter (/usr/local/src/Python-3.12.0/build/lib.macosx-14.1-arm64- 3.12/_tkinter.cpython-312-darwin.so) is missing which suggests that the build process didn't try to build that module. Is there some trick that I'm missing? Some additional bit of fiddling I need to do to get the build process to try to build tkinter? Thanks! Regards, Matt From nad at python.org Thu Dec 7 18:38:00 2023 From: nad at python.org (Ned Deily) Date: Thu, 7 Dec 2023 18:38:00 -0500 Subject: [Pythonmac-SIG] Trouble building tkinter for Aqua In-Reply-To: <1701986926.91.1871@mint-julep.mondoinfo.com> References: <1701986926.91.1871@mint-julep.mondoinfo.com> Message-ID: <57FEEC7F-4436-42D2-8E21-4AFEAA284AD6@python.org> On Dec 7, 2023, at 17:18, Matthew Dixon Cowles wrote: > I'm trying to compile Python 3.12.0 from source on a new ARM MacBook. > I haven't had any trouble except with the tkinter module. I've built > Python from source any number of times before on Linux and macOS, but > previously always with X11. (For the moment, I'm just doing an > ordinary Unix build, not a Framework build.) [...] The process for specifying third-party libs for Python builds changed greatly for Python 3.11 and improved a bit in 3.12. It is now much simpler and more consistent. It's pretty much automatic if you have a version of `pkg-config` installed and use third-party libraries that install .pc files (most do these days). Apple does not ship a version of pkg-config but third-party distributors like Homebrew and MacPorts have it (as well as pre-built versions of all other needed libraries, including Tk). It's also easy to build a non-GPL version (try https://github.com/pkgconf/pkgconf). In any case you may need to set the PKG_CONFIG_PATH env variable to point to the .pc files for your Tcl and Tk. There are some potentially useful examples of using Homebrew and MacPorts in the Python Developers Guide: https://devguide.python.org/getting-started/setup-building/#install-dependencies But otherwise, rather than modifying the Makefile, use the new ./configure options provided to override defaults for the various third-party libraries: $ ./configure --help `configure' configures python 3.12 to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. [...] TCLTK_CFLAGS C compiler flags for TCLTK, overriding pkg-config TCLTK_LIBS linker flags for TCLTK, overriding pkg-config -- Ned Deily nad at python.org -- [] From matt at mondoinfo.com Thu Dec 7 20:03:30 2023 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 08 Dec 2023 01:03:30 -0000 Subject: [Pythonmac-SIG] Trouble building tkinter for Aqua In-Reply-To: <57FEEC7F-4436-42D2-8E21-4AFEAA284AD6@python.org> References: <1701986926.91.1871@mint-julep.mondoinfo.com> <57FEEC7F-4436-42D2-8E21-4AFEAA284AD6@python.org> Message-ID: <1701995470.09.1871@mint-julep.mondoinfo.com> Ned, Success! Thank you. > It's pretty much automatic if you have a version of `pkg-config` > installed Installing pkg-config didn't help. It got rid of the warning at the bottom of configure's output, but configure still reported "_tkinter... missing". > In any case you may need to set the PKG_CONFIG_PATH env variable to > point to the .pc files for your Tcl and Tk. That also didn't help. > Defaults for the options are specified in brackets. > [...] > TCLTK_CFLAGS > C compiler flags for TCLTK, overriding pkg-config > TCLTK_LIBS linker flags for TCLTK, overriding pkg-config But that did. Using: $ ./configure TCLTK_LIBS="-ltcl8.6 -ltk8.6" produced the right result. Tkinter gets built and works (at least it opens a window). That seems weird to me since I have trouble thinking what else would be the default. Unless the default includes X11? In any case, thank you. Regards, Matt