[vtkusers] vtkpython on mac os?
Michka Popoff
michkapopoff at gmail.com
Fri Jan 29 02:37:50 EST 2016
Hi
I made the “-undefined dynamic_lookup” change in ITK some time ago.
This is even now required by the homebrew package managers on OS X.
Citing myself from http://review.source.kitware.com/#/c/20072/1,
(were you also can find the changes I made in cmake to make it work):
> target_link_libraries() would pass the PYTHON_LIBRARY down to the linker.
> For example, when using the python version coming from homebrew:
> -I/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7
>
> Trying to use itk from OS X's system Python would then result in the following error:
> Fatal Python error: PyThreadState_Get: no current thread
> Abort trap: 6
>
> A solution is to not pass the PYTHON_LIBRARY, and use the -undefined dynamic_lookup flag.
>
> I tested this on OS X 10.10 with latest clang. ITK can the be imported from all Pythons with
> are ABI compatible (2.7.x in our case). Tested with OS X Python 2.7.6 and homebrew's Python 2.7.10.
>
> I only allowed this for Clang; not sure if gcc supports this. Maybe some older gcc 4.2 versions on OS X.
>
> OS X supports the flag since 10.3, see:
> https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html <https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html>
>
> Using otool on the .so modules (otool -L _ITKCommonPython.so) shows that there is no more reference of the python library
> when using the -undefined dynamic_lookup flag.
>
> This idea was originally proposed by Tim Smith, on the homebrew-science repo.
An equivalent patch is also waiting for review in simpleITK (http://review.source.kitware.com/#/c/20442/)
Michka
> On 28 Jan 2016, at 21:18, Matthew Brett <matthew.brett at gmail.com> wrote:
>
> Hi,
>
> On Thu, Jan 28, 2016 at 9:22 AM, David E DeMarle
> <dave.demarle at kitware.com <mailto:dave.demarle at kitware.com>> wrote:
>> @Tom
>>
>> I haven't looked at it at all yet but I have a hunch.I am wondering if this
>> is an artifact of how, starting with El Captain, the system python is kind
>> of locked down by be Apple. If that is the case, switching to a third party
>> python (from fink, macports or homebrew) would solve it.
>>
>> If not that, my next guess is that it is the library path management we do
>> in the packaging process to make redistributable binaries that causes the
>> problem. For windows and mac we do these things in different (platform
>> specific) ways which would explain why it can be done on linux and windows
>> but not mac.
>>
>> In my personal use I either build vtk from source (most of my work) or run
>> from the bin directory (for intro to vtk courses). However I really would
>> like to get this nailed down. Likely then we can incorporate the binaries
>> into a wheel and make "pip install vtk" just work. Unfortunately it is
>> unknown when/if I'll find the time to investigate thoroughly (or solve it
>> once I do eh?).
>
> Actually, now I think about it, with the benefit of a couple of years
> of building wheels, I wonder whether this might be possible with only
> a small amount of effort.
>
> My plan would be to build vtk with Python bindings using the standard
> recipe, and the hoover up the pieces into the wheel directory
> structure afterwards.
>
> The previous block that I ran into was the following problem :
> http://vtk.1045678.n5.nabble.com/Fwd-OSX-build-links-directly-with-Python-binary-avoidable-td5731734.html <http://vtk.1045678.n5.nabble.com/Fwd-OSX-build-links-directly-with-Python-binary-avoidable-td5731734.html>
>
> Specifically, the last time I tried, the vtk libraries contained
> absolute path links to the Python dynamic lib, meaning that the built
> vtk could only be used with Python at exactly that path, whereas
> wheels must work for Pythons at any path, such as Pythons in
> virtualenvs. The fix David G suggested was to use "-undefined
> dynamic_lookup" when linking to Python. How hard would it be to apply
> that fix? (I'm afraid my cmake-fu is not good). With that done, it's
> possible I could work out the rest (no promises).
>
> Cheers,
>
> Matthew
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160129/e76fea01/attachment.html>
More information about the vtkusers
mailing list