kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
230 stars 37 forks source link

cadabra2 2.4.2 build issue: type_caster_base.h error: member access into incomplete type 'PyFrameObject' #264

Closed Schamschula closed 2 years ago

Schamschula commented 2 years ago

When building cadabra2 2.4.2 under MacPorts (I'm the package maintainer) I get the following error:

:info:build In file included from /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_math_cadabra2/cadabra2/work/cadabra2-2.4.2/client_server/Server.cc:3:
:info:build In file included from /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_math_cadabra2/cadabra2/work/cadabra2-2.4.2/client_server/./Server.hh:11:
:info:build In file included from /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_math_cadabra2/cadabra2/work/cadabra2-2.4.2/libs/pybind11/include/pybind11/pybind11.h:13:
:info:build In file included from /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_math_cadabra2/cadabra2/work/cadabra2-2.4.2/libs/pybind11/include/pybind11/attr.h:13:
:info:build In file included from /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_math_cadabra2/cadabra2/work/cadabra2-2.4.2/libs/pybind11/include/pybind11/cast.h:16:
:info:build /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_math_cadabra2/cadabra2/work/cadabra2-2.4.2/libs/pybind11/include/pybind11/detail/type_caster_base.h:482:26: error: member access into incomplete type 'PyFrameObject' (aka '_frame')
:info:build             frame = frame->f_back;
:info:build                          ^
:info:build /opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/pytypedefs.h:22:16: note: forward declaration of '_frame'
:info:build typedef struct _frame PyFrameObject;
:info:build                ^

I didn't see this problem with version 2.4.0.2.

kpeeters commented 2 years ago

I think this has more to do with you using Python 3.11 than with Cadabra itself (I don't think there are any changes in Cadabra which could cause this). I will update the bundled pybind11 library to see if that makes the problem go away. Will ping you here again when that's done.

kpeeters commented 2 years ago

I have pushed a commit which updates pybind11 to their current HEAD. Can you try building with that (it's tagged as 2.4.2.1) and let me know?

Schamschula commented 2 years ago

I get an error applying the patch to

patching file libs/pybind11/pybind11/setup_helpers.py
Hunk #16 FAILED at 349.
1 out of 20 hunks FAILED -- saving rejects to file libs/pybind11/pybind11/setup_helpers.py.rej
***************
*** 361,375 ****
      return True

  # Optional parallel compile utility
  # inspired by: http://stackoverflow.com/questions/11013851/speeding-up-build-process-with-distutils
  # and: https://github.com/tbenthompson/cppimport/blostable/cppimport/build_module.py
  # and NumPy's parallel distutils module:
  #              https://github.com/numpy/numpy/blomaster/numpy/distutils/ccompiler.py
- class ParallelCompile(object):
      """
      Make a parallel compile function. Inspired by
-     numpy.distutils.ccompiler.CCompiler_compile and cppimport.

      This takes several arguments that allow you to customize the compile
      function created:
--- 349,381 ----
      return True

+ S = TypeVar("S", bound="ParallelCompile")
+ 
+ CCompilerMethod = Callable[
+     [
+         distutils.ccompiler.CCompiler,
+         List[str],
+         Optional[str],
+         Optional[Union[Tuple[str], Tuple[str, Optional[str]]]],
+         Optional[List[str]],
+         bool,
+         Optional[List[str]],
+         Optional[List[str]],
+         Optional[List[str]],
+     ],
+     List[str],
+ ]
+ 
+ 
  # Optional parallel compile utility
  # inspired by: http://stackoverflow.com/questions/11013851/speeding-up-build-process-with-distutils
  # and: https://github.com/tbenthompson/cppimport/blostable/cppimport/build_module.py
  # and NumPy's parallel distutils module:
  #              https://github.com/numpy/numpy/blomaster/numpy/distutils/ccompiler.py
+ class ParallelCompile:
      """
      Make a parallel compile function. Inspired by
+     numpy.distutils.ccompiler.CCompiler.compile and cppimport.

      This takes several arguments that allow you to customize the compile
      function created:
kpeeters commented 2 years ago

What happens if you do a clean checkout/clone?

Schamschula commented 2 years ago

I get a clean build!

Schamschula commented 2 years ago

Portfile updated to 2.4.2.1.

See: https://github.com/macports/macports-ports/commit/35fa286ea0108db56b570e02b2d4908566e03128