Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on import numba: module '_godot' has no attribute 'print_override' #238

Closed
thetoblin opened this issue Sep 28, 2020 · 14 comments
Closed

Comments

@thetoblin
Copy link

I'm on Ubuntu 18.04, Godot 3.2.2 through standard 64-bit download.

I seem to be able to import python libraries by adding a path to where the python libraries are on disk in the Project Settings> General> Filesystem> Python Script> Path using the Godot editor.

I'm using conda, and I've added
/home/[username]/anaconda3/lib/python3.8;
/home/[username]/anaconda3/lib/python3.8/lib-dynload;/home/[username]/anaconda3/lib/python3.8/site-packages

which seems to make packages such as math, numpy, etc importable in Godot. When I try to import a package called numba however, I get the following error:

  File "/home/[username]/pCloudDrive/03_Passive_freedom/evo_design/models/godot/python_godot_2/Spatial.py", line 4, in <module>
    import numba
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/__init__.py", line 34, in <module>
    from numba.core.decorators import (cfunc, generated_jit, jit, njit, stencil,
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/decorators.py", line 12, in <module>
    from numba.stencils.stencil import stencil
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/stencils/stencil.py", line 11, in <module>
    from numba.core import types, typing, utils, ir, config, ir_utils, registry
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/registry.py", line 4, in <module>
    from numba.core import utils, typing, dispatcher, cpu
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/dispatcher.py", line 15, in <module>
    from numba.core import utils, types, errors, typing, serialize, config, compiler, sigutils
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/compiler.py", line 6, in <module>
    from numba.core import (utils, errors, typing, interpreter, bytecode, postproc,
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/callconv.py", line 11, in <module>
    from numba.core.base import PYOBJECT, GENERIC_POINTER
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/base.py", line 23, in <module>
    from numba.cpython import builtins
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/cpython/builtins.py", line 490, in <module>
    from numba.core.typing.builtins import IndexValue, IndexValueType
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/typing/builtins.py", line 23, in <module>
    @infer_global(print)
  File "/home/[username]/anaconda3/lib/python3.8/site-packages/numba/core/typing/templates.py", line 1149, in register_global
    if getattr(mod, val.__name__) is not val:
AttributeError: module '_godot' has no attribute 'print_override'

That the code refers to 'print_override' suggests to my mind that there might be many errors that is attempted to be printed, but it fails to do so because of the missing attribute of 'print_override'.

Does anyone have any ideas on what the problem could be? Since it works to import other libraries, such as numpy, there could be something specifically wrong with the numba library. Importing numba in a normal python script works however.

@touilleMan
Copy link
Owner

_godot is a python module we provide that is imported when the Godot engine initialize godot-python plugin.
Hence it shouldn't be imported from python code (but importing it shouldn't be a problem in theory).

The stacktrace suggests numba is doing some magic with the builtins, I guess this is clashing with what godot-python is doing when capturing stdout/stderr.

Capturing stdout/stderr used to involve the replacement of the builtins print and print_stacktrace:

def enable_capture_io_streams():
# flush existing buffer
sys.stdout.flush()
sys.stderr.flush()
# make stdout and stderr the custom iostream defined above
sys.stdout = GodotIO.get_godot_stdout_io()
sys.stderr = GodotIO.get_godot_stderr_io()
# override python print function
GodotIO._builtin_print = builtins.print
builtins.print = GodotIO.print_override
# override traceback.print_exception
GodotIO._traceback_print_exception = traceback.print_exception
traceback.print_exception = GodotIO.print_exception_override

However this has changed: now we only replace sys.stdout/stderr. I guess this should fix your current issue.

Can you try with the latest master of Godot-Python ?

@thetoblin
Copy link
Author

Using the "latest master of Godot-Python" means that I have to compile Godot from source, right? (Sorry to ask). So I have to compile Godot from source, and then somehow include Godot-Python.

@touilleMan
Copy link
Owner

Using the "latest master of Godot-Python" means that I have to compile Godot from source, right?

correct

So I have to compile Godot from source

you don't need to compile Godot, Godot-Python is a module loaded from the gdnative interface (so basically Godot loads a shared library that initialize the godot-python module)

tl,dr: you can do:

$ python -m venv venv
$ . ./venv/bin/activate
$ pip install -r requirements.txt
$ scons platform=x11-64 example

This should compile godot-python, install it in examples/pong and run this example project.
From there you should be able to copy what is done in the examples/pong to install the compiled godot-python into your own project (basically you should just have to copy or symlink the build/dist/addons/ folder into your project)

@thetoblin
Copy link
Author

Thanks for replying even to my noob questions! =)

After running

$ python -m venv venv
$ . ./venv/bin/activate

I cloned Godot-Python using git to disc. I then ran pip install -r requirements.txt, which seems to have worked. I then tried to run scons platform=x11-64 example, but it failed due to ``godot_headers/api.json' not found. I therefore went to the Godot headers and cloned it into the godot_headers` folder.

@touilleMan
Copy link
Owner

you miss the godot_headers submodule, to fetch it you should do:

$ git submodule init
$ git submodule update

@thetoblin
Copy link
Author

Received an error again, so I tried to restart the terminal and do everything from scratch. I got an error again. Here is all the terminal outputs:

(base) tobka@lindstrom:~/godot-python$ python -m venv venv
(base) tobka@lindstrom:~/godot-python$ . ./venv/bin/activate
(venv) (base) tobka@lindstrom:~/godot-python$ pip install -r requirements.txt
Collecting scons==3.1.1 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/ab/82/b27f1795375f3112552709f472990560e174fca1a80b9ea66e9cd21a3ffd/scons-3.1.1-py2.py3-none-any.whl
Collecting cython==0.29.21 (from -r requirements.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/9f/05/959e78f2aeade1c9e85a7adc4c376f454ecaeb4cb6b079ca7a85684b69c1/Cython-0.29.21-cp38-cp38-manylinux1_x86_64.whl
Collecting black==19.10b0 (from -r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/fd/bb/ad34bbc93d1bea3de086d7c59e528d4a503ac8fe318bd1fa48605584c3d2/black-19.10b0-py36-none-any.whl
Collecting autopxd==1.0.0 (from -r requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/ca/f9/6c4a7abbc0382294afc118c3ec0b575522fd10eea232fb126a706cdac2a9/autopxd-1.0.0.tar.gz
Collecting jinja2==2.10.3 (from -r requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl
Collecting zstandard==0.13.0 (from -r requirements.txt (line 6))
  Downloading https://files.pythonhosted.org/packages/50/92/8532005f6dd59986bce35af1ad0661c7cff7b677ee0a7fcb0d95293b17c4/zstandard-0.13.0-cp38-cp38-manylinux2010_x86_64.whl (4.0MB)
     |████████████████████████████████| 4.0MB 2.0MB/s 
Collecting attrs>=18.1.0 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/14/df/479736ae1ef59842f512548bacefad1abed705e400212acba43f9b0fa556/attrs-20.2.0-py2.py3-none-any.whl
Collecting click>=6.5 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl
Collecting typed-ast>=1.4.0 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/77/49/51308e8c529e14bb2399ff6d22998583aa9ae189ec191e6f7cbb4679f7d5/typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl
Collecting appdirs (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl
Collecting regex (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/2d/f7/7853ca43f65c6dfb7706b11c960718b90527a2419686b5a2686da904fc3e/regex-2020.9.27-cp38-cp38-manylinux2010_x86_64.whl
Collecting toml>=0.9.4 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/9f/e1/1b40b80f2e1663a6b9f497123c11d7d988c0919abbf3c3f2688e448c5363/toml-0.10.1-py2.py3-none-any.whl
Collecting pathspec<1,>=0.6 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/5d/d0/887c58853bd4b6ffc7aa9cdba4fc57d7b979b45888a6bd47e4568e1cf868/pathspec-0.8.0-py2.py3-none-any.whl
Collecting pycparser (from autopxd==1.0.0->-r requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2==2.10.3->-r requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/4b/20/f6d7648c81cb84815d0be935d5c74cd1cc0239e43eadb1a61062d34b6543/MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl
Collecting cffi>=1.11 (from zstandard==0.13.0->-r requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/c6/60/44b6c54dbbee7d5eafbc34e0a0b67207e85906fe8e36c830dfd3966dde1d/cffi-1.14.3-cp38-cp38-manylinux1_x86_64.whl
Installing collected packages: scons, cython, attrs, click, typed-ast, appdirs, regex, toml, pathspec, black, pycparser, autopxd, MarkupSafe, jinja2, cffi, zstandard
  Running setup.py install for autopxd ... done
Successfully installed MarkupSafe-1.1.1 appdirs-1.4.4 attrs-20.2.0 autopxd-1.0.0 black-19.10b0 cffi-1.14.3 click-7.1.2 cython-0.29.21 jinja2-2.10.3 pathspec-0.8.0 pycparser-2.20 regex-2020.9.27 scons-3.1.1 toml-0.10.1 typed-ast-1.4.1 zstandard-0.13.0
WARNING: You are using pip version 19.2.3, however version 20.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

(venv) (base) tobka@lindstrom:~/godot-python$ git submodule init
(venv) (base) tobka@lindstrom:~/godot-python$ git submodule update
(venv) (base) tobka@lindstrom:~/godot-python$ scons platform=x11-64 example
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cython --fast-fail -3 build/x11-64/pythonscript/_godot.pyx -o build/x11-64/pythonscript/_godot.c
gcc -o build/x11-64/pythonscript/_godot.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/_godot.c
/home/tobka/godot-python/build/x11-64/platforms/Godot_v3.2.2-stable_x11.64 --path examples/pong
Godot Engine v3.2.2.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: GeForce GTX 1050 Ti/PCIe/SSE2
 
ERROR: godot_gdnative_init: Cannot load godot python module
   At: build/x11-64/pythonscript/pythonscript.c:196.
ERROR: _load: No loader found for resource: res://pong.py.
   At: core/io/resource_loader.cpp:285.
ERROR: poll: res://pong.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://pong.py
   At: scene/resources/resource_format_text.cpp:440.
ERROR: load: Failed to load resource 'res://pong.tscn'.
   At: core/io/resource_loader.cpp:208.
ERROR: _load: Failed loading resource: res://pong.tscn.
   At: core/io/resource_loader.cpp:278.
ERROR: start: Failed loading scene: res://pong.tscn
   At: main/main.cpp:1936.
Fatal Python error: PyEval_RestoreThread: NULL tstate
Python runtime state: initialized
Traceback (most recent call last):
  File "build/x11-64/pythonscript/_godot.pyx", line 1, in init _godot
  File "/home/tobka/godot-python/examples/pong/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/__init__.py", line 17, in <module>
    from godot.tags import (
  File "build/x11-64/pythonscript/godot/tags.pyx", line 1, in init godot.tags
  File "build/x11-64/pythonscript/godot/array.pyx", line 1, in init godot.array
  File "build/x11-64/pythonscript/godot/pool_arrays.pyx", line 1, in init godot.pool_arrays
  File "build/x11-64/pythonscript/godot/builtins.pyx", line 1, in init godot.builtins
  File "build/x11-64/pythonscript/godot/bindings.pyx", line 1, in init godot.bindings
  File "build/x11-64/pythonscript/godot/_hazmat/conversion.pyx", line 1, in init godot._hazmat.conversion
AttributeError: partially initialized module 'godot.bindings' has no attribute 'ResourceFormatSaverCrypto' (most likely due to a circular import)
Aborted (core dumped)
scons: *** [examples/pong] Error 134
scons: building terminated because of errors.

@touilleMan
Copy link
Owner

touilleMan commented Sep 29, 2020

Looks like you stumble on something new !
I couldn't reproduce your issue on my computer (Pop!_OS 20.04 LTS) with a clean git checkout of the project and a new virtualenv 😢

The compilation part of your scons example command seems surprisingly short (it displays only the compilation of _godot.pyx), are you sure you're working from a clean git repo with no previous build directory ?

For instance here is the build log I got (ignore the final WARNINGS/ERRORS, they are expected when closing the game):

$ scons example platform=x11-64
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Download&extract https://downloads.tuxfamily.org/godotengine/3.2.2/Godot_v3.2.2-stable_x11.64.zip
Touch("build/dist/addons/pythonscript/.gdignore")
Install file: "misc/release_LICENSE.txt" as "build/dist/addons/pythonscript/LICENSE.txt"
python /home/emmanuel/projects/godot-python-3/tools/generate_bindings.py -i godot_headers/api.json -o build/x11-64/pythonscript/godot/bindings.pyx
python /home/emmanuel/projects/godot-python-3/tools/generate_pool_arrays.py -o build/x11-64/pythonscript/godot/pool_arrays.pyx
python /home/emmanuel/projects/godot-python-3/tools/generate_builtins.py -o build/x11-64/pythonscript/godot/builtins.pyx
Download https://github.com/indygreg/python-build-standalone/releases/download/20200822/cpython-3.8.5-x86_64-unknown-linux-gnu-pgo-20200823T0036.tar.zst
extract_cpython_prebuild(["build/x11-64/platforms/x11-64/cpython_prebuild"], ["build/x11-64/platforms/x11-64/cpython-3.8.5-x86_64-unknown-linux-gnu-pgo-20200823T0036.tar.zst"])
generate_cpython_build(["build/x11-64/platforms/x11-64/cpython_build"], ["build/x11-64/platforms/x11-64/cpython_prebuild"])
cython --fast-fail -3 build/x11-64/pythonscript/_godot.pyx -o build/x11-64/pythonscript/_godot.c
gcc -o build/x11-64/pythonscript/_godot.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/_godot.c
gcc -o build/x11-64/pythonscript/pythonscript.os -c -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -Werror-implicit-function-declaration -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/pythonscript.c
gcc -o build/x11-64/pythonscript/libpythonscript.so -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -Wl,-rpath,'$ORIGIN/lib' -shared build/x11-64/pythonscript/pythonscript.os -lpython3.8
gcc -o build/x11-64/pythonscript/_godot.so -Wl,-rpath,'$ORIGIN/../..' -Wl,-rpath,'$ORIGIN/../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/_godot.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Delete("build/dist/addons/pythonscript/x11-64")
Copy("build/dist/addons/pythonscript/x11-64", "build/x11-64/platforms/x11-64/cpython_build")
Write build/x11-64/platforms/cpython_build_installed_in_dist.marker to mark task complete
Install file: "build/x11-64/pythonscript/_godot.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/_godot.so"
Install file: "build/x11-64/pythonscript/godot/__init__.py" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/__init__.py"
Install file: "build/x11-64/pythonscript/godot/_hazmat/__init__.py" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/__init__.py"
Install file: "build/x11-64/pythonscript/godot/_hazmat/conversion.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/conversion.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/_hazmat/conversion.pyx -o build/x11-64/pythonscript/godot/_hazmat/conversion.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/conversion.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/_hazmat/conversion.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/conversion.so -Wl,-rpath,'$ORIGIN/../../../..' -Wl,-rpath,'$ORIGIN/../../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/_hazmat/conversion.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/_hazmat/conversion.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/conversion.so"
Install file: "build/x11-64/pythonscript/godot/_hazmat/gdapi.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/gdapi.pxd"
Install file: "build/x11-64/pythonscript/godot/_hazmat/gdnative_api_struct.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/gdnative_api_struct.pxd"
Install file: "build/x11-64/pythonscript/godot/_hazmat/internal.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/internal.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/_hazmat/internal.pyx -o build/x11-64/pythonscript/godot/_hazmat/internal.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/internal.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/_hazmat/internal.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/internal.so -Wl,-rpath,'$ORIGIN/../../../..' -Wl,-rpath,'$ORIGIN/../../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/_hazmat/internal.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/_hazmat/internal.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/internal.so"
Install file: "build/x11-64/pythonscript/godot/_version.py" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_version.py"
Install file: "build/x11-64/pythonscript/godot/array.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/array.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/array.pyx -o build/x11-64/pythonscript/godot/array.c
gcc -o build/x11-64/pythonscript/godot/array.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/array.c
gcc -o build/x11-64/pythonscript/godot/array.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/array.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/array.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/array.so"
Install file: "build/x11-64/pythonscript/godot/bindings.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/bindings.pxd"
Install file: "build/x11-64/pythonscript/godot/bindings.pyi" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/bindings.pyi"
cython --fast-fail -3 build/x11-64/pythonscript/godot/bindings.pyx -o build/x11-64/pythonscript/godot/bindings.c
gcc -o build/x11-64/pythonscript/godot/bindings.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -Os -Wno-misleading-indentation -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/bindings.c
gcc -o build/x11-64/pythonscript/godot/bindings.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -Wl,--strip-all -shared build/x11-64/pythonscript/godot/bindings.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/bindings.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/bindings.so"
Install file: "build/x11-64/pythonscript/godot/builtins.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/builtins.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/builtins.pyx -o build/x11-64/pythonscript/godot/builtins.c
gcc -o build/x11-64/pythonscript/godot/builtins.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/builtins.c
gcc -o build/x11-64/pythonscript/godot/builtins.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/builtins.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/builtins.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/builtins.so"
Install file: "build/x11-64/pythonscript/godot/hazmat.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/hazmat.pxd"
Install file: "build/x11-64/pythonscript/godot/pool_arrays.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/pool_arrays.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/pool_arrays.pyx -o build/x11-64/pythonscript/godot/pool_arrays.c
gcc -o build/x11-64/pythonscript/godot/pool_arrays.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/pool_arrays.c
gcc -o build/x11-64/pythonscript/godot/pool_arrays.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/pool_arrays.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/pool_arrays.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/pool_arrays.so"
cython --fast-fail -3 build/x11-64/pythonscript/godot/tags.pyx -o build/x11-64/pythonscript/godot/tags.c
gcc -o build/x11-64/pythonscript/godot/tags.os -c -Wno-unused -O2 -m64 -I/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/tags.c
gcc -o build/x11-64/pythonscript/godot/tags.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/tags.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/tags.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/tags.so"
Install file: "build/x11-64/pythonscript/libpythonscript.so" as "build/dist/addons/pythonscript/x11-64/libpythonscript.so"
Install file: "addons/pythonscript_repl/hack_regular.tres" as "build/dist/addons/pythonscript_repl/hack_regular.tres"
Install file: "addons/pythonscript_repl/hack_regular.ttf" as "build/dist/addons/pythonscript_repl/hack_regular.ttf"
Install file: "addons/pythonscript_repl/input_box.py" as "build/dist/addons/pythonscript_repl/input_box.py"
Install file: "addons/pythonscript_repl/plugin.cfg" as "build/dist/addons/pythonscript_repl/plugin.cfg"
Install file: "addons/pythonscript_repl/plugin.py" as "build/dist/addons/pythonscript_repl/plugin.py"
Install file: "addons/pythonscript_repl/python_repl.py" as "build/dist/addons/pythonscript_repl/python_repl.py"
Install file: "addons/pythonscript_repl/python_repl.tscn" as "build/dist/addons/pythonscript_repl/python_repl.tscn"
SymlinkAction(["examples/pong/addons"], ["build/dist/addons"])
/home/emmanuel/projects/godot-python-3/build/x11-64/platforms/Godot_v3.2.2-stable_x11.64 --path examples/pong
Godot Engine v3.2.2.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: Mesa Intel(R) HD Graphics 520 (SKL GT2)
 
Pythonscript 0.40.0 (CPython 3.8.5.final.0)
ERROR: _load_data: Condition "!f" is true. Returned: ERR_CANT_OPEN
   At: scene/resources/texture.cpp:502.
ERROR: _load: Failed loading resource: res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex.
   At: core/io/resource_loader.cpp:278.
ERROR: _load: Failed loading resource: res://separator.png.
   At: core/io/resource_loader.cpp:278.
ERROR: poll: res://pong.tscn:4 - Parse Error: [ext_resource] referenced nonexistent resource at: res://separator.png
   At: scene/resources/resource_format_text.cpp:440.
ERROR: load: Failed to load resource 'res://pong.tscn'.
   At: core/io/resource_loader.cpp:208.
ERROR: _load: Failed loading resource: res://pong.tscn.
   At: core/io/resource_loader.cpp:278.
ERROR: start: Failed loading scene: res://pong.tscn
   At: main/main.cpp:1936.
WARNING: cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
   At: core/object.cpp:2135.
scons: done building targets.

@thetoblin
Copy link
Author

=) we'll see. Probably my fault at some level.

are you sure you're working from a clean git repo with no previous build directory ?

No, I'm not sure. I barely use git (as you may have noticed). How do I find out if it is a clean git repo? Should I delete everything in the Godot-Python folder and clone it again? Or is there some meta-considerations to take care of as well? I will try to google to see if I can figure it out.

@thetoblin
Copy link
Author

I removed the godot-python repo and cloned it from git again. Then I retraced all the steps. It seems to have worked (see below). I will go figure what the next step is from your comment above. Will return with questions and/or results =)

(base) tobka@lindstrom:~$ git clone https://github.com/touilleMan/godot-python.git
Cloning into 'godot-python'...
remote: Enumerating objects: 169, done.
remote: Counting objects: 100% (169/169), done.
remote: Compressing objects: 100% (107/107), done.
remote: Total 8334 (delta 74), reused 124 (delta 52), pack-reused 8165
Receiving objects: 100% (8334/8334), 5.46 MiB | 1.36 MiB/s, done.
Resolving deltas: 100% (5241/5241), done.

(base) tobka@lindstrom:~/godot-python$ git submodule init
Submodule 'godot_headers' (https://github.com/godotengine/godot_headers.git) registered for path 'godot_headers'
(base) tobka@lindstrom:~/godot-python$ git submodule update
Cloning into '/home/tobka/godot-python/godot_headers'...
Submodule path 'godot_headers': checked out 'f2122198d51f230d903f9585527248f6cf411494'
(base) tobka@lindstrom:~/godot-python$ python -m venv venv
(base) tobka@lindstrom:~/godot-python$ . ./venv/bin/activate

(venv) (base) tobka@lindstrom:~/godot-python$ pip install -r requirements.txt 
Collecting scons==3.1.1 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/ab/82/b27f1795375f3112552709f472990560e174fca1a80b9ea66e9cd21a3ffd/scons-3.1.1-py2.py3-none-any.whl
Collecting cython==0.29.21 (from -r requirements.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/9f/05/959e78f2aeade1c9e85a7adc4c376f454ecaeb4cb6b079ca7a85684b69c1/Cython-0.29.21-cp38-cp38-manylinux1_x86_64.whl
Collecting black==19.10b0 (from -r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/fd/bb/ad34bbc93d1bea3de086d7c59e528d4a503ac8fe318bd1fa48605584c3d2/black-19.10b0-py36-none-any.whl
Collecting autopxd==1.0.0 (from -r requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/ca/f9/6c4a7abbc0382294afc118c3ec0b575522fd10eea232fb126a706cdac2a9/autopxd-1.0.0.tar.gz
Collecting jinja2==2.10.3 (from -r requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl
Collecting zstandard==0.13.0 (from -r requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/50/92/8532005f6dd59986bce35af1ad0661c7cff7b677ee0a7fcb0d95293b17c4/zstandard-0.13.0-cp38-cp38-manylinux2010_x86_64.whl
Collecting typed-ast>=1.4.0 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/77/49/51308e8c529e14bb2399ff6d22998583aa9ae189ec191e6f7cbb4679f7d5/typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl
Collecting attrs>=18.1.0 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/14/df/479736ae1ef59842f512548bacefad1abed705e400212acba43f9b0fa556/attrs-20.2.0-py2.py3-none-any.whl
Collecting pathspec<1,>=0.6 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/5d/d0/887c58853bd4b6ffc7aa9cdba4fc57d7b979b45888a6bd47e4568e1cf868/pathspec-0.8.0-py2.py3-none-any.whl
Collecting regex (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/2d/f7/7853ca43f65c6dfb7706b11c960718b90527a2419686b5a2686da904fc3e/regex-2020.9.27-cp38-cp38-manylinux2010_x86_64.whl
Collecting click>=6.5 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl
Collecting appdirs (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl
Collecting toml>=0.9.4 (from black==19.10b0->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/9f/e1/1b40b80f2e1663a6b9f497123c11d7d988c0919abbf3c3f2688e448c5363/toml-0.10.1-py2.py3-none-any.whl
Collecting pycparser (from autopxd==1.0.0->-r requirements.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2==2.10.3->-r requirements.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/4b/20/f6d7648c81cb84815d0be935d5c74cd1cc0239e43eadb1a61062d34b6543/MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl
Collecting cffi>=1.11 (from zstandard==0.13.0->-r requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/c6/60/44b6c54dbbee7d5eafbc34e0a0b67207e85906fe8e36c830dfd3966dde1d/cffi-1.14.3-cp38-cp38-manylinux1_x86_64.whl
Installing collected packages: scons, cython, typed-ast, attrs, pathspec, regex, click, appdirs, toml, black, pycparser, autopxd, MarkupSafe, jinja2, cffi, zstandard
  Running setup.py install for autopxd ... done
Successfully installed MarkupSafe-1.1.1 appdirs-1.4.4 attrs-20.2.0 autopxd-1.0.0 black-19.10b0 cffi-1.14.3 click-7.1.2 cython-0.29.21 jinja2-2.10.3 pathspec-0.8.0 pycparser-2.20 regex-2020.9.27 scons-3.1.1 toml-0.10.1 typed-ast-1.4.1 zstandard-0.13.0
WARNING: You are using pip version 19.2.3, however version 20.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

(venv) (base) tobka@lindstrom:~/godot-python$ scons platform=x11-64 example
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Download&extract https://downloads.tuxfamily.org/godotengine/3.2.2/Godot_v3.2.2-stable_x11.64.zip
Touch("build/dist/addons/pythonscript/.gdignore")
Install file: "misc/release_LICENSE.txt" as "build/dist/addons/pythonscript/LICENSE.txt"
python /home/tobka/godot-python/tools/generate_bindings.py -i godot_headers/api.json -o build/x11-64/pythonscript/godot/bindings.pyx
python /home/tobka/godot-python/tools/generate_pool_arrays.py -o build/x11-64/pythonscript/godot/pool_arrays.pyx
python /home/tobka/godot-python/tools/generate_builtins.py -o build/x11-64/pythonscript/godot/builtins.pyx
Download https://github.com/indygreg/python-build-standalone/releases/download/20200822/cpython-3.8.5-x86_64-unknown-linux-gnu-pgo-20200823T0036.tar.zst
extract_cpython_prebuild(["build/x11-64/platforms/x11-64/cpython_prebuild"], ["build/x11-64/platforms/x11-64/cpython-3.8.5-x86_64-unknown-linux-gnu-pgo-20200823T0036.tar.zst"])
generate_cpython_build(["build/x11-64/platforms/x11-64/cpython_build"], ["build/x11-64/platforms/x11-64/cpython_prebuild"])
cython --fast-fail -3 build/x11-64/pythonscript/_godot.pyx -o build/x11-64/pythonscript/_godot.c
gcc -o build/x11-64/pythonscript/_godot.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/_godot.c
gcc -o build/x11-64/pythonscript/pythonscript.os -c -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -Werror-implicit-function-declaration -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/pythonscript.c
gcc -o build/x11-64/pythonscript/libpythonscript.so -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -Wl,-rpath,'$ORIGIN/lib' -shared build/x11-64/pythonscript/pythonscript.os -lpython3.8
gcc -o build/x11-64/pythonscript/_godot.so -Wl,-rpath,'$ORIGIN/../..' -Wl,-rpath,'$ORIGIN/../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/_godot.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Delete("build/dist/addons/pythonscript/x11-64")
Copy("build/dist/addons/pythonscript/x11-64", "build/x11-64/platforms/x11-64/cpython_build")
Write build/x11-64/platforms/cpython_build_installed_in_dist.marker to mark task complete
Install file: "build/x11-64/pythonscript/_godot.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/_godot.so"
Install file: "build/x11-64/pythonscript/godot/__init__.py" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/__init__.py"
Install file: "build/x11-64/pythonscript/godot/_hazmat/__init__.py" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/__init__.py"
Install file: "build/x11-64/pythonscript/godot/_hazmat/conversion.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/conversion.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/_hazmat/conversion.pyx -o build/x11-64/pythonscript/godot/_hazmat/conversion.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/conversion.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/_hazmat/conversion.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/conversion.so -Wl,-rpath,'$ORIGIN/../../../..' -Wl,-rpath,'$ORIGIN/../../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/_hazmat/conversion.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/_hazmat/conversion.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/conversion.so"
Install file: "build/x11-64/pythonscript/godot/_hazmat/gdapi.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/gdapi.pxd"
Install file: "build/x11-64/pythonscript/godot/_hazmat/gdnative_api_struct.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/gdnative_api_struct.pxd"
Install file: "build/x11-64/pythonscript/godot/_hazmat/internal.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/internal.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/_hazmat/internal.pyx -o build/x11-64/pythonscript/godot/_hazmat/internal.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/internal.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/_hazmat/internal.c
gcc -o build/x11-64/pythonscript/godot/_hazmat/internal.so -Wl,-rpath,'$ORIGIN/../../../..' -Wl,-rpath,'$ORIGIN/../../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/_hazmat/internal.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/_hazmat/internal.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_hazmat/internal.so"
Install file: "build/x11-64/pythonscript/godot/_version.py" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/_version.py"
Install file: "build/x11-64/pythonscript/godot/array.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/array.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/array.pyx -o build/x11-64/pythonscript/godot/array.c
gcc -o build/x11-64/pythonscript/godot/array.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/array.c
gcc -o build/x11-64/pythonscript/godot/array.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/array.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/array.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/array.so"
Install file: "build/x11-64/pythonscript/godot/bindings.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/bindings.pxd"
Install file: "build/x11-64/pythonscript/godot/bindings.pyi" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/bindings.pyi"
cython --fast-fail -3 build/x11-64/pythonscript/godot/bindings.pyx -o build/x11-64/pythonscript/godot/bindings.c
gcc -o build/x11-64/pythonscript/godot/bindings.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -Os -Wno-misleading-indentation -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/bindings.c
gcc -o build/x11-64/pythonscript/godot/bindings.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -Wl,--strip-all -shared build/x11-64/pythonscript/godot/bindings.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/bindings.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/bindings.so"
Install file: "build/x11-64/pythonscript/godot/builtins.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/builtins.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/builtins.pyx -o build/x11-64/pythonscript/godot/builtins.c
gcc -o build/x11-64/pythonscript/godot/builtins.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/builtins.c
gcc -o build/x11-64/pythonscript/godot/builtins.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/builtins.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/builtins.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/builtins.so"
Install file: "build/x11-64/pythonscript/godot/hazmat.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/hazmat.pxd"
Install file: "build/x11-64/pythonscript/godot/pool_arrays.pxd" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/pool_arrays.pxd"
cython --fast-fail -3 build/x11-64/pythonscript/godot/pool_arrays.pyx -o build/x11-64/pythonscript/godot/pool_arrays.c
gcc -o build/x11-64/pythonscript/godot/pool_arrays.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/pool_arrays.c
gcc -o build/x11-64/pythonscript/godot/pool_arrays.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/pool_arrays.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/pool_arrays.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/pool_arrays.so"
cython --fast-fail -3 build/x11-64/pythonscript/godot/tags.pyx -o build/x11-64/pythonscript/godot/tags.c
gcc -o build/x11-64/pythonscript/godot/tags.os -c -Wno-unused -O2 -m64 -I/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/include/python3.8/ -fdiagnostics-color=always -fPIC -Igodot_headers build/x11-64/pythonscript/godot/tags.c
gcc -o build/x11-64/pythonscript/godot/tags.so -Wl,-rpath,'$ORIGIN/../../..' -Wl,-rpath,'$ORIGIN/../../../..' -m64 -L/home/tobka/godot-python/build/x11-64/platforms/x11-64/cpython_build/lib -shared build/x11-64/pythonscript/godot/tags.os -Lbuild/x11-64/pythonscript -lpython3.8 -lpythonscript
Install file: "build/x11-64/pythonscript/godot/tags.so" as "build/dist/addons/pythonscript/x11-64/lib/python3.8/site-packages/godot/tags.so"
Install file: "build/x11-64/pythonscript/libpythonscript.so" as "build/dist/addons/pythonscript/x11-64/libpythonscript.so"
Install file: "addons/pythonscript_repl/hack_regular.tres" as "build/dist/addons/pythonscript_repl/hack_regular.tres"
Install file: "addons/pythonscript_repl/hack_regular.ttf" as "build/dist/addons/pythonscript_repl/hack_regular.ttf"
Install file: "addons/pythonscript_repl/input_box.py" as "build/dist/addons/pythonscript_repl/input_box.py"
Install file: "addons/pythonscript_repl/plugin.cfg" as "build/dist/addons/pythonscript_repl/plugin.cfg"
Install file: "addons/pythonscript_repl/plugin.py" as "build/dist/addons/pythonscript_repl/plugin.py"
Install file: "addons/pythonscript_repl/python_repl.py" as "build/dist/addons/pythonscript_repl/python_repl.py"
Install file: "addons/pythonscript_repl/python_repl.tscn" as "build/dist/addons/pythonscript_repl/python_repl.tscn"
SymlinkAction(["examples/pong/addons"], ["build/dist/addons"])
/home/tobka/godot-python/build/x11-64/platforms/Godot_v3.2.2-stable_x11.64 --path examples/pong
Godot Engine v3.2.2.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: GeForce GTX 1050 Ti/PCIe/SSE2
 
Pythonscript 0.40.0 (CPython 3.8.5.final.0)
ERROR: _load_data: Condition "!f" is true. Returned: ERR_CANT_OPEN
   At: scene/resources/texture.cpp:502.
ERROR: _load: Failed loading resource: res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex.
   At: core/io/resource_loader.cpp:278.
ERROR: _load: Failed loading resource: res://separator.png.
   At: core/io/resource_loader.cpp:278.
ERROR: poll: res://pong.tscn:4 - Parse Error: [ext_resource] referenced nonexistent resource at: res://separator.png
   At: scene/resources/resource_format_text.cpp:440.
ERROR: load: Failed to load resource 'res://pong.tscn'.
   At: core/io/resource_loader.cpp:208.
ERROR: _load: Failed loading resource: res://pong.tscn.
   At: core/io/resource_loader.cpp:278.
ERROR: start: Failed loading scene: res://pong.tscn
   At: main/main.cpp:1936.
WARNING: cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
   At: core/object.cpp:2135.
scons: done building targets.

@thetoblin
Copy link
Author

This should compile godot-python, install it in examples/pong and run this example project.
From there you should be able to copy what is done in the examples/pong to install the compiled godot-python into your own project (basically you should just have to copy or symlink the build/dist/addons/ folder into your project)

So I have created a new Godot project, and then copied the build/dist/addons/ from the compiled godot-python git repo to the main folder of the new Godot project. The file system now looks like this in Godot:
Screenshot from 2020-09-29 11-29-11

Should I now expect to be able to create .py scripts from Godot? (Because I cannot)
Screenshot from 2020-09-29 11-31-42

Or should I simply create the python scripts manually using a text editor external to the Godot editor?

@touilleMan
Copy link
Owner

The "language" selector should provide a Python option

You are most likely missing the pythonscript.gdnlib file that should be at the root of your project (this tells Godot about the godot-python plugin and how to load it)

On top of that, your project.godot file should contain:

[gdnative]

singletons=[ "res://pythonscript.gdnlib" ]

this is something you can add by hand, or use the Project -> Project Settings -> GDNative menu from within Godot to enable pythonscript.gdnlib

Note you must then restart Godot before being able to use Python from within Godot

@thetoblin
Copy link
Author

I copied the pythonscript.gdnlib from another project where I had installed godot-python through the assetlib into the new Godot project with compiled godot-python. Somehow this seems to have added the singletons information, since when I went to Project -> Project Settings -> GDNative the entry of singletons=[ "res://pythonscript.gdnlib" ] was already present.

Now it works to create python scripts in the Godot Editor, and after adding global paths to my conda installation in the Project Settings > Python Script > Path (which I know will make the project unable to export, I'll solve that later), I seem to be able to import some python modules such as math.

I cannot however import other python modules such as numpy and numba. After thinking, I'm postulating that this has to do with the compilation of godot-python we did through venv, since when I try to import those modules through a venv python shell does not work.

My hypothesized solution is to recompile godot-python but with the added modules of numpy and numba in the requirements.txt file, as per the directions here: https://docs.python.org/3/tutorial/venv.html as such:

numpy==1.19.1
numba==0.51.2

I will return with results or questions. If my thinking is wrong, please feel free to intervene =)

@thetoblin
Copy link
Author

thetoblin commented Sep 29, 2020

Adding numpy and numba to requirements.txt does not appear to have worked. Trying to import them in a python script in the Godot project still gives the ModuleNotFoundError: No module named [numpy/numba]. I've also tried running the Godot project from a venv shell where numpy and numba are installed, but without success.

Note that in retracing the steps (where I updated the requirements.txt) I did not create a new Godot project. Instead I simply replaced the addons folder from the new compiled godot-python. I don't see how this should affect anything, but I mention it in case it might be relevant.

Question
So, the question now is: how do I import python modules (numba, numpy) in the godot project with the godot-python master addon?

Summary of steps
Below is a summary of the steps I took:

# clone godot-python from git
$ git clone https://github.com/touilleMan/godot-python.git

# add desired python modules to the requirements.txt file in the clone folder. Examples:
numpy==1.19.1
numba==0.51.2

# from within the git-cloned godot-python main folder, run:
$ git submodule init
$ git submodule update
$ python -m venv venv
$ . ./venv/bin/activate
$ pip install -r requirements.txt
$ scons platform=x11-64 example

# create new godot project and copy the pythonscript.gdnlib file from another working godot-python project into the main folder of the new project. The file can for example be acquired from a godot-python godot project where godot-python has been installed through the AssetLib.

# Make sure that 
[gdnative]
singletons=[ "res://pythonscript.gdnlib" ]
# is in the Project -> Project Settings -> GDNative menu. This is to enable pythonscript.gdnlib

# Add the python module import path to the Godot project under Project Settings > Python Script > Path. The python path to use can be found by starting a python shell and running:
import sys
print(sys.path)

# This should give something like this, which should be added to the Python Script > Path. Note that adding absolute paths breaks the project export. Another method to enable python module imports needs to be used:
/home/tobka/anaconda3/lib/python38.zip;/home/tobka/anaconda3/lib/python3.8;/home/tobka/anaconda3/lib/python3.8/lib-dynload;/home/tobka/godot-python/venv/lib/python3.8/site-packages

@thetoblin
Copy link
Author

Ok, so the problem of how to import modules was solved by going to the [project dir]/addons/pythonscript/ and running

./x11-64/bin/python3 -m ensurepip
./x11-64/bin/python3 -m pip install numba # where numba is a package name.

This allowed me to import numba and other installed packages in godot-python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants