maiself / godot-python-extension

Python language bindings for the Godot game engine
https://godot-python-extension.readthedocs.io
MIT License
21 stars 4 forks source link

Building without `single_source=true` results in project crashing with "incompatible function arguments" for setattr (missing pybind11 headers) #2

Closed hemebond closed 3 months ago

hemebond commented 6 months ago

I've successfully built the latest godot-python-extension code using the latest Godot 4.2.1 download. I copied the test project and tried to run it. It restarts once to enable the extension, but afterwards crashes with this error:

$ Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org
Vulkan API 1.3.224 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 980 Ti

ERROR: Traceback (most recent call last):
  File "godot/_internal/__init__.py", line 137, in initialize
    importlib.import_module('godot._python_extension')
  File "godot/_python_extension/__init__.py", line 7, in <module>
    from . import python_language
  File "godot/_python_extension/python_language.py", line 10, in <module>
    from .python_script import PythonScript
  File "godot/_python_extension/python_script.py", line 12, in <module>
    from . import python_script_instance
  File "godot/_python_extension/python_script_instance.py", line 59, in <module>
    class PythonScriptInstanceInfo(gde.GDExtensionScriptInstanceInfo, metaclass=_script_instance_info_meta):
  File "godot/_python_extension/python_script_instance.py", line 34, in __new__
    res = utils.apply_attrs(res,
          ^^^^^^^^^^^^^^^^^^^^^^
  File "godot/_internal/utils/general_utils.py", line 233, in apply_attrs
    setattr(obj, name, value)
TypeError: (): incompatible function arguments. The following argument types are supported:
    1. (self: _gdextension.GDExtensionScriptInstanceInfo, arg0: std::optional<function>) -> None

Invoked with: <_gdextension.GDExtensionScriptInstanceInfo object at 0x7efe97d50db0>, <function PythonScriptInstanceInfo.set_func at 0x7efe97d40ae0>

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

   at: initialize_python_module (src/extension/extension.cpp:262)
maiself commented 6 months ago

Thanks for reporting this! Not sure how I missed it. I'm hoping to have more time to spend on the project soon, this will be the first thing I'll fix. For now you should be able to build like this, or with something similar (the important part is the single_source=true):

scons -j12 platform=linux single_source=true use_llvm=true

When I find time I'll also update the documentation and project description with more details. I'll keep this issue open until this is actually fixed with build documentation written.

Please keep opening new issues for anything else you run into, there's plenty I will miss on my own, and it really helps with motivation to know someone is interested in using the project!

maiself commented 3 months ago

With d678a2f it should now be possible to build both as single source and separate source without issue. Still need to update build documentation tho.

maiself commented 3 months ago

Now tracking documentation tasks in #8, so will close this as the issue is otherwise fixed.