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

Suggestion: Do a windows build available #31

Closed
Ranoller opened this issue Jul 28, 2017 · 18 comments
Closed

Suggestion: Do a windows build available #31

Ranoller opened this issue Jul 28, 2017 · 18 comments

Comments

@Ranoller
Copy link

Linux is a wonderfull system, but, by the fact, most godot users (me include) have windows in their computers. If is needed some testing in godot-python binding, maybe there will be a compilation for windows available in the main page of Godot. I know that 90% of godot dev´s have linux, but 90% of godot users have windows (Percentages invented with a reliability of 90%)

@touilleMan
Copy link
Owner

I've start working on a windows build by cross-compiling, however this is on hold given I'm focusing on the Godot's pluginscript module.
Basically pluginscript would allow to dynamically plug a script langage into a regular Godot build. Once this is working Godot-Python would only be a .so (well technically 2 .so given we have to ship libpython with it) distributed from the Godot asset store.
Once this is done, doing a windows build should be much easier (and a total must have given how much gamer are on windows as you said ^^)

@blurymind
Copy link

looking forward to this :D windows build will of course be awesome too

@Zireael07
Copy link

I'd love to see windows availability for this.

@faststare
Copy link

any update?

@touilleMan
Copy link
Owner

The build system has been greatly simplified, so windows build should not be that of a trouble
Biggest hassle is the gdnative wrapper shared labrary is not provided with the Godot 3 alpha binaries so you have to recompile Godot just for this :(
I don't have a windows machine ready to do the compilation, but if somebody is motivated to try I can help ;-)

@touilleMan
Copy link
Owner

godot-gdnative-wrapper-0416ca2fd22506689cd93e00fe6bd61e4e0841d1.zip
I've worked a bit on this last night.

Beforehand

To build godot-python library, we need 3 things:

  • Godot GDnative includes (usually located at godot/modules/gdnative/include)
  • Godot GDnative wrapper static library (build with Godot when enabling option gdnative_wrapper=yes, usually located at godot/bin/libgdnative_wrapper_code.<platform>.tools.64.a
  • Python build directory. It can be a CPython build dir (obtain by cloning the CPython repository, compiling the project and installing it, a rule in the Makefil simplify this) or a pypy release (you need to use the linux 64 portable ones)

Godot

Godot can be cross compiled from linux without any trouble:

$ scons platform=windows LD=i686-w64-mingw32-gcc CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ gdnative_wrapper=yes

Note we need mingw32 cross-compiler installed so on ubuntu it's apt install g++-mingw-w64 gcc-mingw-w64 (not 100% sure, I've done this a long time ago)

Python

The Python build directory is used in the SConstruct to extract two thing:

  • the python shared library binary
  • the python include folder containing all it headers

Given those thing vary depending on the backend chosen (lib/libpython3.so vs bin/libpypy3-c.so for the python shared library) and the platform (on windows we won't have .so but .dll) there should be some work here (I've already done some)

Using CPython

Now for the not-so-bright side:

  • CPython cannot be cross-compiled (the build system exit telling you it's not possible...)
  • CPython official windows binary doesn't provide the include folder
  • We cannot just use the include folder provided from the CPython repository because we need the pyconfig.h header which is dynamically generated depending on the compilation options :/

Using Pypy

  • pypy provides precompiled binary with the includes, but given pypy3 (pypy for Python3) is still in beta version they don't provide a windows version

Solution ?

From what I see, we have to compile CPython on a windows platform and use this build to do the compilation.
If somebody want to do that, I've provided the gdnative wrapper library and headers cross-compiled on my machine (hence you don't have to compile Godot which should save some time).
If you do that, I'll apreciate if you provide me your CPython build, then I should be able to cross-compile godot-python on my machine.

@touilleMan
Copy link
Owner

For the record, I've made big improvements on this (see the appveyor branch)
I should be able to release a windows version for Godot 3 beta 2 (beta 1 contains a bug in the GDnative api) \o/

@touilleMan
Copy link
Owner

A release for windows is available here:
https://github.com/touilleMan/godot-python/releases/tag/v0.10.0-rc1

However it needs test (I've generated it on appveyor, from where I cannot run it easily) so help needed here !
(I suspect the load of python.dll from pythonscript.dll may cause crash given they are not in the same folder...)

@bruno-ortiz
Copy link

@touilleMan how do i import it in godot?

@touilleMan
Copy link
Owner

@bruno-ortiz you should only have to drop the pythonscript folder and pythonscript.gdnlib file in your project main directory (be sure to use the right bits version of godot-python according to your godot binary)

I've already spotted (and fixed ! see release https://github.com/touilleMan/godot-python/releases/tag/v0.10.0-rc2) some errors in the v0.10.0-rc1.
I've also found some errors in GDnative which has been corrected but are not available in Godot 3.0 beta2.

  • new script should be prefilled by a generic template but are not New script template emtpy on windows #45
  • when writing into the python file with Godot editor, linting is triggered which produce a crash (fix done in Godot master, so only occurs with Godot beta 2), the workaround is for the moment not using the builtin editor but instead modify python script with an external editor
  • not sure if scripts load and get called properly (even if python has been initialized correctly from within Godot...)

@Ranoller
Copy link
Author

I have an godot build from 10/01/18 so i will try your binding... If i can write some phyton!

@deep-gaurav
Copy link

deep-gaurav commented Jan 11, 2018

I dunno why but I get "No nativescript_init" found in pythonscript/libpythonscript.so, I tried both rc1 and rc2 of cpython and pypy, on Linux 64

OK, I downloaded the latest daily build and enabled Singleton, now Godot hangs when creating a python script.

I made .py file externally and it's Working great now!!,.

@Ranoller
Copy link
Author

I try to load the library (Cpython rc2) in the editor (Godot 3 32 bit- compiled 10/01/18- Win7 32 bit without VisualStudio Instaled):

WARNING: not found: editor_plugins/enabled
WARNING: not found: editor_plugins/enabled
WARNING: not found: editor_plugins/enabled
WARNING: not found: editor_plugins/enabled
Can't open dynamic library: F:/_Godot3_Proyecto_Vacio/pythonscript/pythonscript.dll. Error: Error 126: No se puede encontrar el mᅢᄈdulo especificado.

modules\gdnative\gdnative.cpp:305 - No valid library handle, can't get symbol from GDNative object
modules\gdnative\nativescript\nativescript.cpp:1024 - No nativescript_init in "res://pythonscript/pythonscript.dll" found
Establecer library
modules\gdnative\gdnative.cpp:213 - No valid library handle, can't terminate GDNative object
WARNING: not found: editor_plugins/enabled
Can't open dynamic library: F:/_Godot3_Proyecto_Vacio/pythonscript/pythonscript.dll. Error: Error 126: No se puede encontrar el mᅢᄈdulo especificado.

Godot ask me to this library: VCRUNTIME140.dll
There is no library, plugin or singleton in project settings.

@touilleMan
Copy link
Owner

Ho yeah ! VCruntime is needed by CPython but not provided on the embedded distribution I'm using (see https://docs.python.org/3.6/using/windows.html#embedded-distribution)
You can get vcruntime by installing CPython on your computer (the msi version, not the embedded one ^^).
Otherwise you can use the vcruntime I've enclosed in this message (just drop it in the same directory than the python3.dll)
vcruntime140.zip

@Ranoller
Copy link
Author

Do you have 32 bit version of the runtime? This is not working.... I suppose is 64 bit version.

I can´t install nothing in this computer... need to put manually in folder.

@Ranoller
Copy link
Author

Ranoller commented Jan 12, 2018

Ok... i can´t execute phyton-binding in this computer. Now is asking my to api-ms-win-crt-runtime 1-1-0.dll..... I will try Phyton-Godot in a system with 64 bit and VS installed and report....

Edit: I´m thinking in a use-problem of a native library in godot... For now, you can open a godot project in any system (win 32 - 64 - linux- mac) without problem, but linking a library fix the project to selected platform?... Is any workaround for that?

@touilleMan
Copy link
Owner

Here should be the 32bits version of vcruntime140 (taken from my own computer C:\\Windows\System 32

vcruntime140_x86.zip

@thorsvartefoss
Copy link

I would really appreciate it if someone would make a step by step guide for us newbies for how to install and get this working on Windows. I tried on Linux yesterday, but I've never used Linux before, so that was a definite no-go for me.

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

8 participants