This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: setup.py not picking up tkinter headers from non-system macOS Tcl and Tk frameworks
Type: compile error Stage: resolved
Components: Build Versions: Python 3.9
process
Status: closed Resolution: duplicate
Dependencies: Superseder: _tkinter built on macOS 10.14 does not link to Tcl and Tk in /Library/Frameworks
View: 34956
Assigned To: ned.deily Nosy List: anthonypjshaw, ned.deily
Priority: normal Keywords: patch

Created on 2019-12-30 08:35 by anthonypjshaw, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17753 closed anthonypjshaw, 2019-12-30 10:50
Messages (4)
msg359026 - (view) Author: anthony shaw (anthonypjshaw) * (Python triager) Date: 2019-12-30 08:35
./configure && make -j4 is returning:

Failed to build these modules:
_tkinter                                                       

I'm running macOS 10.15.2, with the SDK installed using `xcode-select --install` (no funny business)

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework/

xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

If I debug setup.py, I can see it's eagerly returning the wrong path (/System)

On a REPL, if I do:
>>> import setup
>>> setup.macosx_sdk_root()
'/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

So the path is correct, but I can see in setup.py that detect_tkinter_darwin() will break inside the loop if /System/Library/Frameworks/Tk.framework/Versions/Current  exists (which it does), but it doesn't contain the headers, it contains 3 directories:

Resources      Tk             _CodeSignature

I think detect_tkinter_darwin should be updated so that framework_dirs scans macosx_sdk_root first, but I don't know what other scenarios this might break.

I'd be happy to submit a patch for my scenario but it looks like this whole function needs tests so each platform change and scenario as they come up. There's loads of other issues on BPO related.
msg359027 - (view) Author: anthony shaw (anthonypjshaw) * (Python triager) Date: 2019-12-30 08:39
I also can't see how this condition would ever match, since macosx_sdk_root() is not in the list being iterated upon,
https://github.com/python/cpython/blob/master/setup.py#L1774
msg359034 - (view) Author: anthony shaw (anthonypjshaw) * (Python triager) Date: 2019-12-30 10:53
This comes down to a logic bug in detect_tkinter_darwin(), shown in https://github.com/python/cpython/pull/17753/files#r361956102
msg369222 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-18 13:59
Thanks for the report and the PR. Yes, detect_tkinter_darwin() had a number of problems due mainly to how Apple has first deprecated and more recently removed the option to have header files installed in the running system. Plus some nasty quirks of how the Tcl and Tk frameworks are built make it difficult to use them without hacks for embedding while supporting Python build options.  Your analysis was helpful. In the end, I tried to fix this and some more general problems in detect_tkinter_darwin() with PR 20171 for Issue34956 which will be available in 3.9.0b1.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83343
2020-05-18 13:59:47ned.deilysetstatus: open -> closed

superseder: _tkinter built on macOS 10.14 does not link to Tcl and Tk in /Library/Frameworks
title: setup.py not picking up tkinter headers -> setup.py not picking up tkinter headers from non-system macOS Tcl and Tk frameworks
messages: + msg369222
versions: + Python 3.9
resolution: duplicate
stage: patch review -> resolved
2019-12-30 12:12:56ned.deilysetassignee: ned.deily
2019-12-30 10:53:22anthonypjshawsetmessages: + msg359034
2019-12-30 10:50:54anthonypjshawsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17189
2019-12-30 08:39:04anthonypjshawsetmessages: + msg359027
2019-12-30 08:35:14anthonypjshawsetnosy: + ned.deily
2019-12-30 08:35:06anthonypjshawcreate