hhatto / pgmagick

pgmagick is a yet another boost.python based wrapper for GraphicsMagick/ImageMagick.
MIT License
147 stars 33 forks source link

Not able to install pgmagick on MacOS Big Sur version 11.6 #74

Open foodspotapp opened 2 years ago

foodspotapp commented 2 years ago

Hi.

I tried to install pgmagick on my new Apple M1 Macbook Air.

I followed the instructions to install on Mac OS,

brew install python brew install graphicsmagick brew install boost-python3 pip3 install pgmagick

I also have python 2.7.6 installed in my system. Problem arises in the last step, saying that 'boost/python.hpp' file not found. Below is the complete log from running the last command.

biglion@pgmagick: pip3 install pgmagick Collecting pgmagick Using cached pgmagick-0.7.6.tar.gz (363 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: pgmagick Building wheel for pgmagick (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [24 lines of output] include header path: /opt/homebrew/include/GraphicsMagick boost lib: boost_python39 library path: /opt/homebrew/lib/libGraphicsMagick++ Found version 1.3.37 in file /opt/homebrew/lib/pkgconfig/GraphicsMagick++.pc GraphicsMagick version: 1.3.37 running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-universal2-3.9 creating build/lib.macosx-10.9-universal2-3.9/pgmagick copying pgmagick/_version.py -> build/lib.macosx-10.9-universal2-3.9/pgmagick copying pgmagick/init.py -> build/lib.macosx-10.9-universal2-3.9/pgmagick copying pgmagick/api.py -> build/lib.macosx-10.9-universal2-3.9/pgmagick running build_ext building 'pgmagick._pgmagick' extension creating build/temp.macosx-10.9-universal2-3.9 creating build/temp.macosx-10.9-universal2-3.9/src gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/usr/local/include/ -I/opt/homebrew/include/GraphicsMagick -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c ./src/_Blob.cpp -o build/temp.macosx-10.9-universal2-3.9/./src/_Blob.o -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_27 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_26 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_24 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_22 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_20 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_19 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_6 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_x -D_LIBRARY_VERSION="1.3.37" ./src/_Blob.cpp:1:10: fatal error: 'boost/python.hpp' file not found

include <boost/python.hpp>

           ^~~~~~~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pgmagick Running setup.py clean for pgmagick Failed to build pgmagick Installing collected packages: pgmagick Running setup.py install for pgmagick ... error error: subprocess-exited-with-error

× Running setup.py install for pgmagick did not run successfully. │ exit code: 1 ╰─> [24 lines of output] include header path: /opt/homebrew/include/GraphicsMagick boost lib: boost_python39 library path: /opt/homebrew/lib/libGraphicsMagick++ Found version 1.3.37 in file /opt/homebrew/lib/pkgconfig/GraphicsMagick++.pc GraphicsMagick version: 1.3.37 running install running build running build_py creating build creating build/lib.macosx-10.9-universal2-3.9 creating build/lib.macosx-10.9-universal2-3.9/pgmagick copying pgmagick/_version.py -> build/lib.macosx-10.9-universal2-3.9/pgmagick copying pgmagick/init.py -> build/lib.macosx-10.9-universal2-3.9/pgmagick copying pgmagick/api.py -> build/lib.macosx-10.9-universal2-3.9/pgmagick running build_ext building 'pgmagick._pgmagick' extension creating build/temp.macosx-10.9-universal2-3.9 creating build/temp.macosx-10.9-universal2-3.9/src gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/usr/local/include/ -I/opt/homebrew/include/GraphicsMagick -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c ./src/_Blob.cpp -o build/temp.macosx-10.9-universal2-3.9/./src/_Blob.o -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_27 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_26 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_24 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_22 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_20 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_19 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_6 -DPGMAGICK_LIB_GRAPHICSMAGICK_1_3_x -D_LIBRARY_VERSION="1.3.37" ./src/_Blob.cpp:1:10: fatal error: 'boost/python.hpp' file not found

include <boost/python.hpp>

           ^~~~~~~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> pgmagick

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

rdupz commented 2 years ago

Got the same problem. I'm using conda. After using conda install boost it worked.

keshe4ka commented 1 year ago

I have the same problem :(

Platform: MacOS Sonoma 14.0

scharlau commented 4 months ago

Same issue here with Sonoma 14.5 on M3 chip.

scharlau commented 4 months ago

Dug into this some more and found the path was not being set correctly for homebrew on Apple chips, so I modified the setup.py file. I ran it with pip install path/to/my/local/version/of/pgmagick-master

However, while I now have the path to the missing python.hpp file at /opt/homebrew/opt/boost/include/boost/python.hpp, it is still not being picked up. I'll keep looking at what to amend, but I'm just guessing here at the moment.

Any suggestions of what to try would be great.

My setup.py file is attached with added txt extension to keep GitHub happy.

setup.py.txt

scharlau commented 3 months ago

I found a way to make this work. There are two issues that make it trickier for those of us on newer MacBooks with Apple chips. One, is the paths as mentioned previously. Two, is the Apple version of g++, which is Apple Clang, that needs to have a flag set for compiling the C++ code.

Part one: setting the paths I've included the updated version of the setup.py file (as txt to keep GitHub happy). The difference this time is added code around line 40 to check platform, and then set the path for include_dirs to the correct path for homebrew on Apple chips. This meant the file found the correct files, and added boost to the path.

Part two: adding the correct flag for GCC This took longer to sort. I thought I could modify the src/makefile and add the flags to the ones there at the top. This didn't help. This file never seemed to be called, or was read at the wrong time. I tried adding 'echo' statements, but they never appeared. Eventually I discovered the solution is much simpler: you add the command, and add flags to the command line as shown at stackoverflow

This meant my new install command was CXXFLAGS=-std=c++11 pip install 'path to pgmagick source code' (without quotes)

This took some time to run, but worked. I can now hopefully get the rest of this working correctly. For now, I guess add a few extra lines to the setup.py and add a note to the Readme file, and people can get back to using to your library.

setup.py.txt