wlav / cppyy

Other
391 stars 40 forks source link

Problems Building with Pip on OSX 12.3 #110

Closed nimski closed 1 year ago

nimski commented 1 year ago

Hi!

I'm looking to use cppyy on an existing project that uses pip, so I'm hoping to install it the same way rather than conda-forge. Installing via pip install cppyy goes well but fails when building the wheel for CPyCppyy. I've affexed the 8 errors generated by clang.

Clang was installed via xcode-tools. Here's the output of clang --version:

Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.4.0

Any help would be greatly appreciated, and sorry if I missed something obvious.

Build error:

AD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
              defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1))
                                              ^
      src/Executors.cxx:373:58: error: expected unqualified-id
      static inline PyObject* PyComplex_FromComplex(const std::complex<T>& c) {
                                                               ^
      src/Executors.cxx:373:58: error: invalid parameter name: '_Complex' is a keyword
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/complex.h:37:17: note: expanded from macro 'complex'
      #define complex _Complex
                      ^
      src/Executors.cxx:373:58: error: parameter declarator cannot be qualified
      static inline PyObject* PyComplex_FromComplex(const std::complex<T>& c) {
                                                          ~~~~~^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/complex.h:37:17: note: expanded from macro 'complex'
      #define complex _Complex
                      ^
      src/Executors.cxx:373:58: error: C++ requires a type specifier for all declarations
      static inline PyObject* PyComplex_FromComplex(const std::complex<T>& c) {
                                                    ~~~~~      ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/complex.h:37:17: note: expanded from macro 'complex'
      #define complex _Complex
                      ^
      src/Executors.cxx:373:65: error: expected ')'
      static inline PyObject* PyComplex_FromComplex(const std::complex<T>& c) {
                                                                      ^
      src/Executors.cxx:373:46: note: to match this '('
      static inline PyObject* PyComplex_FromComplex(const std::complex<T>& c) {
                                                   ^
      src/Executors.cxx:374:34: error: use of undeclared identifier 'c'
          return PyComplex_FromDoubles(c.real(), c.imag());
                                       ^
      src/Executors.cxx:374:44: error: use of undeclared identifier 'c'
          return PyComplex_FromDoubles(c.real(), c.imag());
                                                 ^
      src/Executors.cxx:378:20: error: expected unqualified-id
      static inline std::complex<T> PyComplex_AsComplex(PyObject* pycplx) {
                         ^
      197 warnings and 8 errors generated.
      error: command '/usr/bin/clang' 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 CPyCppyy
wlav commented 1 year ago

Seems to be caused by Executors.cxx doing #include <complex.h> instead of #include <complex> and thus bringing in the C rather than C++ headers. Is fixed in repo (https://github.com/wlav/CPyCppyy/commit/bf37247f9b72c3b14e673ed24a7a3628a2da2750). Not sure how to work around it other than applying that patch locally.

nimski commented 1 year ago

Thanks so much @wlav!

wlav commented 1 year ago

Released with cppyy 2.4.2 and its dependencies.