Hello, recently I have been thinking about adding a python interpreter support to my game project. As a support library an excelent choice seems to be pybind11 — https://pybind11.readthedocs.io/en/stable/basics.html . So here’s the question for you : would I be able to grab that library for snap core18 or that would require so much effort that I should give up ? Please refer …
I answer my own question : there seems to be packages for core20 and I upgraded my snapcraft.yaml to use that base…
https://pastebin.com/NFGVBn1q How do I modify this config to have working pybind11 library ?
Here’s what I have so far after 2hours session: https://pastebin.com/raw/JBQ4T85x it ends up with error. I get :
[ 2%] Building CXX object CMakeFiles/opendungeons-plus.dir/source/ai/KeeperAIType.cpp.o In file included from /usr/include/pybind11/pytypes.h:12, from /usr/include/pybind11/cast.h:13, from /usr/include/pybind11/attr.h:13, from /usr/include/pybind11/pybind11.h:44, from /usr/include/pybind11/embed.h:12, from /build/opendungeons-plus/parts/opendungeons-plus/src/source/modes/ConsoleInterface.h:25, from /build/opendungeons-plus/parts/opendungeons-plus/src/source/network/ODServer.h:22, from /build/opendungeons-plus/parts/opendungeons-plus/src/source/ai/BaseAI.cpp:29: /usr/include/pybind11/detail/common.h:112:10: fatal error: Python.h: No such file or directory 112 | #include <Python.h>
Where to get <Python.h> , please don’t say from mallshop !
Hmm now I get something like that :
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.9.so (found version "3.9.5") -- Found PythonInterp: /usr/bin/python3.8 (found version "3.8.10") CMake Error at /usr/lib/cmake/pybind11/FindPythonLibsNew.cmake:96 (message): Python config failure: Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py) Call Stack (most recent call first): /usr/lib/cmake/pybind11/pybind11Tools.cmake:16 (find_package) /usr/lib/cmake/pybind11/pybind11Config.cmake:100 (include) CMakeLists.txt:518 (find_package)
Here it says I should install python-distutils : https://stackoverflow.com/questions/63823964/importerror-cannot-import-name-sysconfig-from-distutils-usr-lib-python3-8 but that doesn’t change anything. My snapcraft.yaml : https://pastebin.com/raw/SRW9FYUc . Please help !
python3-dev depends on
python3-distutils (>= 3.8.2-1~) so you will have that at build time. Replace your libpython3.8-dev dependency with the higher level
python3-dev and it should work out.
Thanks for the reply. However the highest avaliable library — libpython3.9 — does not work – I keep getting the same old error. What shall I do to get libpython3.10 or libpython3.11 then ? Would I need to rewrite the snapcraft.yaml file to upgrade to core22 ? If so I would need someone’s help …
Yes you should try upgrading to core 22, here is some help for you --> (micro) Howto migrate from core20 to core22 , follow this guide and try upgrading to core22, but here is a quick reminder its well known that python extension of core22 is broken so when building with core22 use snapcraft from edge channel as it has some fix for it, Good Luck
Hmmm seems the pybind11 library should be in build-packages FIRST. Seems I managed to have a working snap, except in the logs I get :
Priming opendungeons-plus + snapcraftctl prime The 'opendungeons-plus' part is missing libraries that are not included in the snap or base. They can be satisfied by adding the following entries to the existing stage-packages for this part: - libpython3.8 'grade' property not specified: defaulting to 'stable'.
Does it matter much ?
> tom@localhost:~> snap run opendungeons-plus > /snap/opendungeons-plus/110/bin/desktop-launch: line 51: /home/tom/.config/user-dirs.dirs: Permission denied > /snap/opendungeons-plus/110/bin/desktop-launch: line 108: /home/tom/snap/opendungeons-plus/110/.config/user-dirs.dirs: Permission denied > realpath: '': No such file or directory > realpath: '': No such file or directory > realpath: '': No such file or directory > realpath: '': No such file or directory > realpath: '': No such file or directory > realpath: '': No such file or directory > realpath: '': No such file or directory > realpath: '': No such file or directory > rm: cannot remove '/home/tom/snap/opendungeons-plus/110/.local/share/icons': Permission denied > /snap/opendungeons-plus/110/usr/games/opendungeons-plus: error while loading shared libraries: libOIS.so.1.5.0: cannot open shared object file: No such file or directory > tom@localhost
For some reason this recipe doesn’t link the libOIS library properly. https://pastebin.com/FtC8dunm
Someone nice on IRC libera chat modified the snapcraft.yaml file and everything now runs and whistles !
I’m glad it’s working now. I should have been more direct and said to use