Python 3.4.1 installer on Mac links Python to old Tcl/Tk

Ned Deily nad at acm.org
Sat Oct 4 01:53:23 EDT 2014


In article <m0n3n3$48j$1 at dont-email.me>,
 Kevin Walzer <kw at codebykevin.com> wrote:
> On 10/3/14, 3:55 PM, Ned Deily wrote:
> > Even if there were no incompatibilities, on OS X with Tcl and Tk (and
> > other) frameworks, the version number is embedded in the path to the
> > shared library and the linker normally creates an absolute path at that.
> 
> Is this because Python lacks the concept of stubs?
> 
> A Tcl library compiled for 8.5 can be loaded into 8.6 with no 
> re-compiling required because of stubs.

It has nothing to do with Python per se; that's just the way linking 
with OS frameworks work.  Both Apple and ActiveState install their 
versions of Tcl and Tk as frameworks.  What gets installed and what the 
OS X compilers and linkers expect is something like this:

$ cd /Library/Frameworks/Tk.framework/Versions/8.5
$ ls -l
total 5720
drwxr-xr-x+ 3 root  wheel      272 Nov 24  2013 Headers
drwxr-xr-x+ 2 root  wheel      340 Nov 24  2013 PrivateHeaders
drwxr-xr-x+ 4 root  wheel      272 Nov 24  2013 Resources
-rw-r--r--+ 1 root  wheel  2905000 Oct 27  2013 Tk
-rw-r--r--+ 1 root  wheel    12240 Oct 27  2013 libtkstub8.5.a
-rw-r--r--+ 1 root  wheel     4622 Oct 27  2013 tkConfig.sh
$ file Tk
Tk: Mach-O universal binary with 2 architectures
Tk (for architecture x86_64): Mach-O 64-bit dynamically linked shared 
library x86_64
Tk (for architecture i386):   Mach-O dynamically linked shared library 
i386
$ file libtkstub8.5.a
libtkstub8.5.a: Mach-O universal binary with 2 architectures
libtkstub8.5.a (for architecture x86_64): current ar archive random 
library
libtkstub8.5.a (for architecture i386):   current ar archive random 
library
$ otool -D Tk
Tk:
/Library/Frameworks/Tk.framework/Versions/8.5/Tk

When Python or other programs link with a framework, they use the cc or 
ld -framework option, rather than -l:
    -framework Tcl -framework Tk

That causes the linker to look in the default search paths for 
frameworks, /Library/Frameworks followed by /System/Library/Frameworks.  
The install names of the framework shared libraries used are embedded in 
the Mach-O file (executable, bundle, or shared library) produced by ld.  
So the stub library archive is there but is not used, AFAIK.

There may be other ways to do it but that's how Python has always linked 
to Tcl and Tk.  FWIW, that's how both Apple's and ActiveState's wish 
executables are linked as well:

$ more /usr/local/bin/wish8.5
#!/bin/sh
"$(dirname 
$0)/../../../Library/Frameworks/Tk.framework/Versions/8.5/Resources/Wish.
app/Contents/MacOS/Wish" "$@"
$ otool -L 
/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Wish.app/Contents
/MacOS/Wish
/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Wish.app/Contents
/MacOS/Wish:
   /Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility 
version 8.5.0, current version 8.5.15)
   /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility 
version 8.5.0, current version 8.5.15)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 125.2.0)
   /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa 
(compatibility version 1.0.0, current version 15.0.0)
   /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon 
(compatibility version 2.0.0, current version 152.0.0)
   /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit 
(compatibility version 1.0.0, current version 275.0.0)
   /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current 
version 625.0.0)

There's more info about frameworks in various Apple developer docs and 
in the man pages for ld, otool, and install_name_tool.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list