I built an C++ extension module for python to help my algos. The result is a .pyd file (I’m on windows) wich works fine when I test it: I can import it and use the functions inside.
However the game engine does not seem to be able to read this file. It says: "No module named myModule"
The path of import should be correct (my algocore imports the module and other python files from the same location).
So is the game engine unable to read this type of file? Or do I need to build my module in a different way?
Edit: Question that may be related: What python version is the game engine using? (My module is compiled for 3.6)
I can get a C++ extension to run fine (under linux, and on the game servers - which are also running linux) by compiling to a .so shared library file.
But I believe .pyd files are for use in windows, so it may be troublesome getting it to work on the game servers.
You will likely have to install something like minGW so you can compile using gcc instead of windows cl.exe. You could then specify the compiler to use your setup file for python setup.py build. I have not tested this but I think it would work.
Personally though, I will probably just copy my code to a linux environment and build it there. There will probably be less room for errors.
To cross-compile, you must download the Python source code and cross-compile Python itself for the platform you are targeting - it is not possible from a binary installation of Python (as the .lib etc file for other platforms are not included.) In practice, this means the user of a 32 bit operating system will need to use Visual Studio 2008 to open the PCBuild/PCbuild.sln solution in the Python source tree and build the “x64” configuration of the ‘pythoncore’ project before cross-compiling extensions is possible.
This, however, is only talking about cross-compiling to different Windows versions. It does not discuss (that I saw anywhere) the capability of using gcc for the compiler. You would have to specify the libraries and linker required manually which I can personally say from experience is tedious since setup.py build relies on many things, including ones specific to Python.
These dependencies can be tracked down (I did for a while, just for fun ), but it really isn’t worth it when you can just quickly install linux (dual-boot or vm) and then copy your code over (I just used github). Doing it this way is as easy as running almost the exact same command, python3 setup.py build and it just works.
Edit:
Note that I have not tested any of this on the C1 servers yet, but I am assuming it will be fine since my .so file is created and works normally.