Open stef30360 opened 4 years ago
I have just got PythonMagick working under Mojave 10.14.6 with Python3.8 & Homebrew today.
1. Install required dependencies
We need brew's llvm clang because the MacOS version in XCode doesn't support OpenMP.
$ brew install --with-toolchain llvm
Check:
$ clang++ --version
clang version 10.0.1
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
Now the obvious stuff
$ brew install python3 boost boost-python3 imagemagick
This gave me the following versions as of Sep 2020, for posterity:
$ convert --version
Version: ImageMagick 7.0.10-30 Q16 x86_64 2020-09-21 https://imagemagick.org
$ python3.8
Python 3.8.5 (default, Jul 21 2020, 10:42:08)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
$ otool -L /usr/local/lib/libboost_system.dylib
/usr/local/lib/libboost_system.dylib:
@rpath/libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
$ otool -L /usr/local/lib/libboost_python38.dylib
/usr/local/lib/libboost_python38.dylib:
/usr/local/opt/boost-python3/lib/libboost_python38.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
$ ls /usr/local/Cellar/boost
1.73.0
2. set environment variables
$ export BOOST_ROOT=/usr/local/Cellar/boost/1.73.0
3. Modify configure script We need to point configure to libboost_python38.dylib instead of the generic libboost_python.so, which is fine under Linux but will cause "library missing" errors during configure under MacOS.
Edit line 17046 and 17458 of configure script to be:
ax_python_lib=boost_python38
I'll raise an issue to get this fixed.
4. Configure
We need to point to the correct brew version of clang & clang++, otherwise will get OpenMP errors since the XCode version of clang doesn't support it. Also specifically point to python3.8, and the brew location for the boost libraries.
$ ./configure CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ PYTHON=python3.8 CPPFLAGS="-I/usr/local/Cellar/boost/1.73.0/include" LDFLAGS="-L/usr/local/lib"
Toward the end, you should see:
...
checking for python3.8 version... 3.8
checking for python3.8 platform... darwin
checking for python3.8 script directory... ${prefix}/lib/python3.8/site-packages
checking for python3.8 extension module directory... ${exec_prefix}/lib/python3.8/site-packages
checking for python3.8... /usr/local/bin/python3.8
checking for a version of Python >= '2.1.0'... yes
checking for a version of Python >= '2.4'... yes
checking for the distutils Python package... yes
checking for Python include path... -I/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/include/python3.8
checking for Python library path... -L/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib -lpython3.8
checking for Python site-packages path... /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
checking python extra libraries... -ldl -framework CoreFoundation
checking python extra linking flags... -Wl,-stack_size,1000000 -framework CoreFoundation /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python
checking consistency of all components of python development environment... yes
checking for boostlib >= 1.20.0... yes
checking whether the Boost::Python library is available... yes
checking whether boost_python38 is the correct library... yes
checking for boostlib >= 1.20.0... yes
checking whether the Boost::Python library is available... (cached) yes
checking whether boost_python38 is the correct library... (cached) yes
checking for MAGICKCORE... yes
checking for MAGICKPP... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
...
5. Build & install
Nothing left for it but:
$ make -j8 && make install
6. Test
Go to your home directory and try this
$ cd ; python3.8 -c "import PythonMagick"
If no errors appear, all good! If you get a missing symbol error, there is a compiler mismatch between python, libboost-python, or imagemagick.
Hi, Have you got a way to Install under MacOs Mojave ? regards SR