Trouble building visual python extension on MacOSX 10.8… with python3.2
Hi Distutils Folks, I'm hoping someone on the distutils list may have some hints about discovering the incantation necessary to produce a working boost-linked python extension for ptyhon.org Python-3.2.3 on MacOS 10.8. Here's my situation. I'm attempting to help out with a wxPython port of visual python, or vpython http://www.vpython.org and particularly at https://github.com/BruceSherwood/vpython-wx. I cooked up a setup.py script that works fine (i.e., builds the extension) on python2.7 for both MacOSX 10.6, 10.7 and 10.8 (using the python.org 32/64 binary for python-2.7.3). I'm attempting to use the same, or similar script to build the same extension using python3.2, but while it works OK on MacOSX 10.6, it fails to produce a working extension on MacOS 10.8 using the same MacOSX 10.6 SDK. Here's the setup.py: https://dl.dropbox.com/u/20562746/dist-build/setup.py At first I thought it was different versions of Xcode, but no, that can't be on the 10.8 system I have Xcode 3.2.5 installed and defined the link: /Developer -> /Developer-3.2.5 With the link I have the *exact* *same* files in /Developer/SDKs/MacOSX10.6.sdk on both systems. The setup.py script produces exactly the same output on both systems: On 10.6 -> https://dl.dropbox.com/u/20562746/dist-build/build_on_10.6.txt On 10.8 -> https://dl.dropbox.com/u/20562746/dist-build/build_on_10.8.txt Except for one error message in the 10.6 build: ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks//Python.framework/Python, missing required architecture x86_64 in file (but I'm not smart enough to tell how that matters.. I'm not using that Python Framework!) But when I import the extension on 10.8 I get: aluminum:visual_common steve$ python3.2 -c 'import cvisual' Traceback (most recent call last): File "<string>", line 1, in <module> SystemError: initialization of cvisual raised unreported exception aluminum:visual_common steve$ I tried to step through the debugger to see what was going on... but I don't know boost well enough to sort it out: https://dl.dropbox.com/u/20562746/dist-build/visualDebug.txt Finally.. I thought I'd try to inspect the produced .so file. With otool I figured out how to dump the symbol table (-vI) and found that while they have exactly the same size, they have very different symbol tables: 10.6 -> https://dl.dropbox.com/u/20562746/dist-build/t6.txt 10.8 -> https://dl.dropbox.com/u/20562746/dist-build/t8.txt Strange! Anyway... if anyone has a hint and/or clue how to determine what's going on... how can I get this to build property on 10.8 I'd really appreciate it. BTW the full source for the entire project is here: https://github.com/BruceSherwood/vpython-wx thanks! -steve
I should mention that at least one of the differences here:
aluminum:visual_common steve$ grep Indirect ~/t6.txt
Indirect symbols for (__TEXT,__symbol_stub1) 1442 entries
Indirect symbols for (__DATA,__nl_symbol_ptr) 2168 entries
Indirect symbols for (__DATA,__la_symbol_ptr) 1442 entries
Indirect symbols for (__TEXT,__symbol_stub1) 1442 entries
Indirect symbols for (__DATA,__nl_symbol_ptr) 2168 entries
Indirect symbols for (__DATA,__la_symbol_ptr) 1442 entries
aluminum:visual_common steve$ grep Indirect ~/t8.txt
Indirect symbols for (__TEXT,__symbol_stub1) 1442 entries
Indirect symbols for (__DATA,__nl_symbol_ptr) 2168 entries
Indirect symbols for (__DATA,__la_symbol_ptr) 1442 entries
Also the shared libs themselves are here:
10.6 build -> https://dl.dropbox.com/u/20562746/dist-build/cvisual.so-10.6-build.zip
10.8 build -> https://dl.dropbox.com/u/20562746/dist-build/cvisual.so-10.8-build.zip
aluminum:visual_common steve$ ls -la ~/3.2sitepack/VPython-10.6-Build/visual_common/cvisual.so cvisual.so
-rwxr-xr-x 1 steve steve 12708776 Feb 13 14:25 /Users/steve/3.2sitepack/VPython-10.6-Build/visual_common/cvisual.so
-rwxr-xr-x 1 steve steve 12708776 Feb 18 06:44 cvisual.so
On Feb 18, 2013, at 10:07 AM, Steve Spicklemire
Finally.. I thought I'd try to inspect the produced .so file. With otool I figured out how to dump the symbol table (-vI) and found that while they have exactly the same size, they have very different symbol tables:
10.6 -> https://dl.dropbox.com/u/20562746/dist-build/t6.txt
10.8 -> https://dl.dropbox.com/u/20562746/dist-build/t8.txt
Strange!
In article
I'm hoping someone on the distutils list may have some hints about discovering the incantation necessary to produce a working boost-linked python extension for ptyhon.org Python-3.2.3 on MacOS 10.8.
Sorry, I don't have any experience with boost but I can give you a few general hints.
Here's my situation. I'm attempting to help out with a wxPython port of visual python, or vpython http://www.vpython.org and particularly at https://github.com/BruceSherwood/vpython-wx. I cooked up a setup.py script that works fine (i.e., builds the extension) on python2.7 for both MacOSX 10.6, 10.7 and 10.8 (using the python.org 32/64 binary for python-2.7.3). I'm attempting to use the same, or similar script to build the same extension using python3.2, but while it works OK on MacOSX 10.6, it fails to produce a working extension on MacOS 10.8 using the same MacOSX 10.6 SDK.
Here's the setup.py: https://dl.dropbox.com/u/20562746/dist-build/setup.py
At first I thought it was different versions of Xcode, but no, that can't be on the 10.8 system I have Xcode 3.2.5 installed and defined the link:
/Developer -> /Developer-3.2.5
With the link I have the *exact* *same* files in /Developer/SDKs/MacOSX10.6.sdk on both systems.
The setup.py script produces exactly the same output on both systems:
On 10.6 -> https://dl.dropbox.com/u/20562746/dist-build/build_on_10.6.txt
On 10.8 -> https://dl.dropbox.com/u/20562746/dist-build/build_on_10.8.txt
Except for one error message in the 10.6 build:
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks//Python.framework/Python, missing required architecture x86_64 in file
(but I'm not smart enough to tell how that matters.. I'm not using that Python Framework!)
When you specify an SDK to the compiler front-end via sysroot, searches for headers and libraries files may be automatically prefixed with the SDK. So, for example, specifying -isysroot /Developer/SDKs/MacOSX10.6.sdk along with -framework Python will search for the framework in: /Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks then /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks So you should make sure that, in all of the SDKs that you use, /Developer/SDks/.../Library/Frameworks points to the right thing. You may want it to be symlinked to your /Library/Frameworks directory if that's where you have python3.2 installed. I believe that was the default case with Xcode 3, although with the last release of Xcode 3 (3.2.6) I recall that there was a problem with the symlinks that it generated; not sure about 3.2.5. With the latest versions of Xcode 4, I believe it is the case that no symlinks are created automatically. So you either have to create them yourself or install copies of the frameworks you want directly into the SDKs Library directory. (Note, don't alter the SDK System/Library directory there!) Also, be aware that with current Xcode 4's, the SDKs are no longer installed into /Developer, in fact, nothing is. They are included within Xcode.app itself. You can use xcodebuild with either Xcode 3 or 4 to find the SDK location: xcodebuild -version -sdk macosx Path xcodebuild -version -sdk macosx10.6 Path Another thing - and this may be significant. When using -framework Python, I expect that build tool chain will follow the Versions/Current link in the framework to find the appropriate version. As it stands, Python 3 installs normally do not change that Current link. So it may be possible that Python 2 include files and libraries are being used wherever you have -framework Python. So you should ensure that, during the build, the Library/Frameworks/Python.frameworks linked to from the SDK has Current pointing to 3.2. Or change the build to avoid -framework Python and link to the desired Framework -I and -L directories directly.
Finally.. I thought I'd try to inspect the produced .so file. With otool I figured out how to dump the symbol table (-vI) and found that while they have exactly the same size, they have very different symbol tables:
Have you checked the dynamic link dependencies of the built .so files with otool -L to make sure any dynamic links are to the paths of the frameworks and libraries you expect? In general, when building a complex project intended to run on multiple releases and with so many pieces like this outside of Xcode, my experience is that the safest approach is to be conservative and build on the oldest supported system. Yes, it is possible to install older Xcode releases on newer systems and build there but it is also really easy for a slip-up to occur and not be noticed until it's too late. For example, up until recently in the builds of Python itself, there was a long-standing undetected bug along these lines where the system version of the sqlite3 headers was mistakenly being picked up rather than the SDK version. I should also mention that there are some unfortunate differences in OS X specific Distutils behavior between Python 3.2.x and 2.7.x , particularly in regard to dealing with extension module building on newer OS X systems in the absence of SDKs. I *believe* those differences should be all sorted out in the upcoming 3.2.4 and 2.7.4 maintenance releases, which should be out in the near future. From a very quick glance at what you are doing here, I can't think of anything that would affect it, though. Good luck! -- Ned Deily, nad@acm.org
Aha! I think this turned out to be the trouble.
THANK YOU!
Having said that, I didn't specify -framework Python explicitly, but distutils put that *and* the correct '-I' (but not '-L') line for the corresponding include directory within the correct version of the framework. I guess it was getting the wrong library?
Anyway.. I appreciate your suggestion to use the oldest supported system, but it's getting harder to keep such system around!
thanks again,
-steve
On Feb 18, 2013, at 2:38 PM, Ned Deily
Another thing - and this may be significant. When using -framework Python, I expect that build tool chain will follow the Versions/Current link in the framework to find the appropriate version. As it stands, Python 3 installs normally do not change that Current link. So it may be possible that Python 2 include files and libraries are being used wherever you have -framework Python. So you should ensure that, during the build, the Library/Frameworks/Python.frameworks linked to from the SDK has Current pointing to 3.2. Or change the build to avoid -framework Python and link to the desired Framework -I and -L directories directly.
In article <80A14FCD-7722-437F-A030-D5A71E4F43A6@spvi.com>,
Steve Spicklemire
Aha! I think this turned out to be the trouble.
THANK YOU!
Glad it helped.
Anyway.. I appreciate your suggestion to use the oldest supported system, but it's getting harder to keep such system around!
Yes but a more practical solution is to use virtual OS X machines. Although, technically speaking, the license text for older releases of OS X did not allow them to be run as VMs, the latest releases (10.7+) do as long as they are run on OS X hosts. For older releases (10.5 and 10.6), there are a couple of tricks needed to make the client work; they should be easily googleable. I've had great success with VMware Fusion. -- Ned Deily, nad@acm.org
participants (2)
-
Ned Deily
-
Steve Spicklemire