Skip to content

Commit 20f6c41

Browse files
MacOSX: detect the architectures supported by
Tk.framework and build _tkinter only for those architectures. This replaces the hardcoded solution that is no longer valid now that 64-bit capable versions of Tk are available on OSX.
1 parent ff8c84f commit 20f6c41

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

setup.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,19 +1499,17 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
14991499
# architectures.
15001500
cflags = sysconfig.get_config_vars('CFLAGS')[0]
15011501
archs = re.findall('-arch\s+(\w+)', cflags)
1502-
if 'x86_64' in archs or 'ppc64' in archs:
1503-
try:
1504-
archs.remove('x86_64')
1505-
except ValueError:
1506-
pass
1507-
try:
1508-
archs.remove('ppc64')
1509-
except ValueError:
1510-
pass
1511-
1512-
for a in archs:
1513-
frameworks.append('-arch')
1514-
frameworks.append(a)
1502+
fp = os.popen("file %s/Tk.framework/Tk | grep 'for architecture'"%(F,))
1503+
detected_archs = []
1504+
for ln in fp:
1505+
a = ln.split()[-1]
1506+
if a in archs:
1507+
detected_archs.append(ln.split()[-1])
1508+
fp.close()
1509+
1510+
for a in detected_archs:
1511+
frameworks.append('-arch')
1512+
frameworks.append(a)
15151513

15161514
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
15171515
define_macros=[('WITH_APPINIT', 1)],

0 commit comments

Comments
 (0)