[CMake] problems with VTK python module installation on OSX (after a custom build)

Darren Weber darren.weber.lists at gmail.com
Tue Sep 2 18:49:26 EDT 2008


I've tried to bend python a little using the sys.path, but this also fails:


[ dweber at weber-mbp ~/src/kitware/VTK_build ]$ pythonPython 2.5.2
(r252:60911, Feb 22 2008, 07:57:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/usr/local/lib/python2.5/site-packages')
>>> print sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages',
'/usr/local/lib/python2.5/site-packages']
>>>
>>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.5/site-packages/vtk/__init__.py", line 41, in
<module>
    from common import *
  File "/usr/local/lib/python2.5/site-packages/vtk/common.py", line 7, in
<module>
    from libvtkCommonPython import *
ImportError:
dlopen(/usr/local/lib/python2.5/site-packages/vtk/libvtkCommonPython.so,
10): Library not loaded: libvtkCommonPythonD.5.2.dylib
  Referenced from:
/usr/local/lib/python2.5/site-packages/vtk/libvtkCommonPython.so
  Reason: image not found
>>>






On Tue, Sep 2, 2008 at 3:35 PM, Darren Weber
<darren.weber.lists at gmail.com>wrote:

>
> I've discovered a minor problem with the VTK python installation (from
> build) on OSX.  I'm basically having library path issues and I don't know
> how to bend VTK build-install to fit OSX python or how to bend OSX python to
> use the default VTK install paths.
>
>
> First, some explanation of the OSX python installation(s).
>
> The OSX python installation is a framework that's installed into
>
> /System/Library/Frameworks/Python.framework
> AND
> /Library/Frameworks/Python.framework
>
> I'm no expert on python installations for OSX, so I'm puzzled, even
> confused by the installation "polymorphism".  It get's better.  If you use
> macports, you can also have an installation somewhere below /opt/local/....
> Moreover, each of these installation paths has the capacity for management
> of multiple versions of python - that's becoming standard fare on most
> platforms (I think).  So, for example, under /Library/.... there are a bunch
> of symlinks to manage the current version, eg (under the /System path):
>
> weber-mbp:Python root# ls -l
> /System/Library/Frameworks/Python.framework/Versions/
> total 8
> drwxr-xr-x   7 root  wheel  238 Feb 21  2008 2.3
> drwxr-xr-x  11 root  wheel  374 Aug 22 17:59 2.5
> lrwxr-xr-x   1 root  wheel    3 Feb 21  2008 Current -> 2.5
> weber-mbp:Python root#
>
> AND (under the /Library path):
>
> weber-mbp:Python root# ls -l /Library/Frameworks/Python.framework/
> total 24
> lrwxr-xr-x  1 root  admin   24 Aug 29 16:13 Headers ->
> Versions/Current/Headers
> lrwxr-xr-x  1 root  admin   23 Aug 29 16:13 Python ->
> Versions/Current/Python
> lrwxr-xr-x  1 root  admin   26 Aug 29 16:13 Resources ->
> Versions/Current/Resources
> drwxr-xr-x  4 root  admin  136 Feb 21  2008 Versions
> weber-mbp:Python root# ls -l /Library/Frameworks/Python.framework/Versions/
> total 8
> drwxrwxr-x  10 admin  admin  340 Feb 21  2008 2.5
> lrwxr-xr-x   1 root   admin    3 Aug 29 16:13 Current -> 2.5
>
>
> As far as I can tell, there are no symlinks between these installations to
> a common path, so they appear to be entirely independent installations.
> That's probably to protect the "system" installation from other "library"
> installations (eg, I downloaded an install package directly from the
> python.org site and I think it installs into the /Library path).
>
>
> NOW, the VTK installation script sets the --prefix="/usr/local/" when doing
> the install.  In my case, the install command was echoed to the screen
> during 'make install' as follows:
>
> running cd "/Users/dweber/src/kitware/VTK_build/Wrapping/Python" &&
> /Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 setup.py
> install --prefix="/usr/local"  2>&1
>
> So this is the only site-package in the /usr/local python path, ie:
>
> [ dweber at weber-mbp ~/src/kitware/VTK_build ]$ ll
> /usr/local/lib/python2.5/site-packages/
> total 4.0K
> -rw-r--r--  1 root wheel  248 Sep  2 14:42 VTK-5.2.0-py2.5.egg-info
> drwxr-xr-x 54 root wheel 1.8K Sep  2 14:42 vtk/
>
> That is, it seems this is not the default installation path for python
> modules on OSX.  So, when I started the default python shell and tried to
> import vtk, it failed with a message about no module found :-(
>
> I then took some care to specify my default python installation for the
> bash shell (I chose to use the /Library/... path as my default).  I then
> double checked this setting in the ccmake config and ran the build again.
> This time, I noticed that the installation went into /usr/local again.  Then
> I ran a post-install command as root:
>
> # cd <VTK_build_path>/Wrapping/Python/
> # /Library/Frameworks/Python.framework/Versions/Current/bin/python setup.py
> install 2>&1
>
> Without the --prefix option for the installation, this installed into the
> /Library/... path, ie:
>
>
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk
>
>
> However, despite my attempt to get the module installed in the "right"
> place, I get this traceback during the import:
>
>  dweber at weber-mbp ~/src/kitware/VTK_build ]$ which python
> /Library/Frameworks/Python.framework/Versions/Current/bin/python
> [ dweber at weber-mbp ~/src/kitware/VTK_build ]$
> [ dweber at weber-mbp ~/src/kitware/VTK_build ]$ python
> Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import vtk
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/__init__.py",
> line 41, in <module>
>     from common import *
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/common.py",
> line 7, in <module>
>     from libvtkCommonPython import *
> ImportError:
> dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/libvtkCommonPython.so,
> 10): Library not loaded: libvtkCommonPythonD.5.2.dylib
>   Referenced from:
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/libvtkCommonPython.so
>   Reason: image not found
> >>>
>
>
> This is where the libvtkCommon* libs are at:
>
> /usr/local/lib/python2.5/site-packages/vtk/libvtkCommonPython.so
> /usr/local/lib/vtk-5.2/libvtkCommonPythonD.5.2.0.dylib
> /usr/local/lib/vtk-5.2/libvtkCommonPythonD.5.2.dylib
> /usr/local/lib/vtk-5.2/libvtkCommonPythonD.dylib
>
>
> So then I get crazy with symlink hacks like this:
>
> $ cd
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk
> ### First I verify how to run a for loop to get all the dylib files:
> $ for f in *.so; do nf=`basename $f .so`; echo ""; echo $nf; echo `ls -l
> /usr/local/lib/vtk-5.2/${nf}D.dylib`  ; done
> ### Then I create all the symlinks:
> $ for f in *.so; do nf=`basename $f .so`; echo ""; echo "${nf}D.dylib"; ln
> -s /usr/local/lib/vtk-5.2/${nf}D.dylib ${nf}D.dylib  ; done
>
> However, that doesn't work because the symlinks are not specific to the VTK
> version.... so:
>
> $ cd
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk
> $ rm *.dylib
> $ for f in *.so; do nf=`basename $f .so`; echo ""; echo "${nf}D.dylib"; ln
> -s /usr/local/lib/vtk-5.2/${nf}D.5.2.dylib ${nf}D.5.2.dylib  ; done
>
> BUT, it still doesn't work....
>
> As you can see, I'm in OSX library hell with no thread to find my way back
> out!  (Things are so much easier on Debian - Ubuntu!).
>
> Any help much appreciated!
>
> Thanks, Darren
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080902/c9429747/attachment.htm>


More information about the CMake mailing list