Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d097efe

Browse files
Merged revisions 74798 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r74798 | ronald.oussoren | 2009-09-15 20:33:33 +0200 (Tue, 15 Sep 2009) | 8 lines 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 2d352d0 commit d097efe

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

setup.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,19 +1274,26 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
12741274
# architectures.
12751275
cflags = sysconfig.get_config_vars('CFLAGS')[0]
12761276
archs = re.findall('-arch\s+(\w+)', cflags)
1277-
if 'x86_64' in archs or 'ppc64' in archs:
1278-
try:
1279-
archs.remove('x86_64')
1280-
except ValueError:
1281-
pass
1282-
try:
1283-
archs.remove('ppc64')
1284-
except ValueError:
1285-
pass
12861277

1287-
for a in archs:
1288-
frameworks.append('-arch')
1289-
frameworks.append(a)
1278+
tmpfile = os.path.join(self.build_temp, 'tk.arch')
1279+
if not os.path.exists(self.build_temp):
1280+
os.makedirs(self.build_temp)
1281+
1282+
# Note: cannot use os.popen or subprocess here, that
1283+
# requires extensions that are not available here.
1284+
os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(F, tmpfile))
1285+
fp = open(tmpfile)
1286+
detected_archs = []
1287+
for ln in fp:
1288+
a = ln.split()[-1]
1289+
if a in archs:
1290+
detected_archs.append(ln.split()[-1])
1291+
fp.close()
1292+
os.unlink(tmpfile)
1293+
1294+
for a in detected_archs:
1295+
frameworks.append('-arch')
1296+
frameworks.append(a)
12901297

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

0 commit comments

Comments
 (0)