I just tried the Mac GDCM 3.0.8 distribution from github
https://github.com/malaterre/GDCM/releases/download/v3.0.8/GDCM-3.0.8-Darwin-x86_64.tar.bz2
with Python 3.8.5. The first problem was that libgdcmMSFF.3.0.8.dylib has an absolute path reference to
/usr/local/lib/libgdcmopenjp2.7.dylib so import of gdcm fails because it cannot fine libgdcmopengp2.7.dylib. I fixed that with
install_name_tool -change /usr/local/lib/libgdcmopenjp2.7.dylib @rpath/libgdcmopenjp2.7.dylib libgdcmMSFF.3.0.8.dylib
Then "import gdcm" crashes importing _gdcmswig.so _because that library contains an aboslute reference to /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python which is the Python 3.8 installed by homebrew. But I am using a different Python 3.8 installation and I have that homebrew one, so gdcm tries to pull in the Python library from a different Python. To fix this I changed the _gdcmswig.so _using
install_name_tool -change /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python @executable_path/../Library/Frameworks/Python.framework/Versions/3.8/Python _gdcmswig.so
Then gdcm imported and worked for me.
While I figured out these problems and can work around them here is what I would love to have. I am trying to include gdcm in a Python based visualization package UCSF ChimeraX. I'd love to have a gdcm distribution that has gdcm for Python 3.8 as a self-contained Python package, ie a directory gdcm in site-packages with contents
with all library paths in _gdcmswig.so pointing to the libraries in the same directory and the .dylib files with correct relative references to the other dylib files they depend on. I could drop this gdcm directory into any Python 3.8 site-packages and it would just work. The ChimeraX app is on Windows and Linux too and I'd like the same on those systems. I can massage the current gdcm distributions into this form but it is a lot of trouble and the suggested packaging would make using gdcm in Python much easier to setup. Thanks!
Last edit: Tom Goddard 2020-09-26