cbrunet / python-poppler

Python binding to Poppler-cpp pdf library
GNU General Public License v2.0
97 stars 15 forks source link

installation fails on mac due to c++11 not being used #76

Closed bzamecnik closed 1 year ago

bzamecnik commented 1 year ago

It fails like in https://stackoverflow.com/questions/45047508/error-unknown-type-name-constexpr-during-make-in-mac-os-x:

 FAILED: src/cpp/document.cpython-310-darwin.so.p/document.cpp.o
c++ -Isrc/cpp/document.cpython-310-darwin.so.p -Isrc/cpp -I../../src/cpp -I../../subprojects/pybind11-2.10.3/include -I/opt/homebrew/Cellar/poppler/23.04.0/include/poppler/cpp -I/opt/homebrew/Cellar/poppler/23.04.0/include/poppler -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -DNDEBUG -Wall -Winvalid-pch -O3 -MD -MQ src/cpp/document.cpython-310-darwin.so.p/document.cpp.o -MF src/cpp/document.cpython-310-darwin.so.p/document.cpp.o.d -o src/cpp/document.cpython-310-darwin.so.p/document.cpp.o -c ../../src/cpp/document.cpp

      ../../subprojects/pybind11-2.10.3/include/pybind11/detail/common.h:547:15: error: unknown type name 'constexpr'
      inline static constexpr size_t size_in_ptrs(size_t s) {

To fix it add default_options : ['c_std=c11', 'cpp_std=c++11'] to project() in meson.build:

project(
    'python-poppler', 
    'cpp', 
    version: '0.4.0', 
    license: 'GNU General Public License v2 (GPLv2)', 
    # license_files: 'LICENSE.txt',
    meson_version: '>=1.0.0',
    default_options : ['c_std=c11', 'cpp_std=c++11']
)

Then installation works:

$ pip3 install meson meson-python
$ pip3 install python_poppler

Successfully installed python-poppler-0.4.0
cbrunet commented 1 year ago

Thank you for reporting. If you are familiar with Github Actions, it could be great to add a pipeline for building and testing python-poppler on mac os. It could even be used to publish prebuild binaries on PyPI. Do not hesitate to open a PR for that!

bzamecnik commented 1 year ago

@cbrunet Thanks for a tip. I was not aware that the GitHub CI runners already support MacOS. It could potentially reduce the need to install meson and some other libs. But once they're installed compilation from a wheel is very fast (10s on M1).

cbrunet commented 1 year ago

It could potentially reduce the need to install meson and some other libs. But once they're installed compilation from a wheel is very fast (10s on M1).

It is more a matter of how easy it is to install the latest version of poppler-cpp? Distributing wheels would allow to distribute a working poppler-cpp together.

bzamecnik commented 1 year ago

It's a matter of brew install poppler. Very easy.

Wheels would be bound to a given poppler version, which may not be the latest. Poppler gets released every month.