Open touilleMan opened 4 years ago
What I do for now on a project I want to use Pythonscript support for, is following the described method here, but just for some package loader project which then loads the actual game package and switches to that scene.
With this method the actual game files are still in a single package and only the loader files are exposed in the directory structure.
This is highly relevant to my current interests.
Let me ask you - is it possible to load the game/application on another machine after performing this export? Eg; one that does not have python installed into the host system.
Another way of asking is "is python embedded into godot's engine after this is done?"
is it possible to load the game/application on another machine after performing this export?
yes ;-)
Another way of asking is "is python embedded into godot's engine after this is done?"
Godot-Python ships it own Python interpreter totally isolated from the system.
This issue is really interesting for me. If you have some idea for a real export I could help.
Hi @gustavi !
I've started working on this issue a couple of weeks ago, but I have put it on hold to focus on a better plugin install&update experience (the assetlib is not well suited for big platform-dependent project such as this one), this should allow me to do much more frequent release so I consider it should come first ;-)
Considering what should be done for the export:
1) create an export plugin (using the PluginEditor.add_export_plugin)
2) during export, the plugin should copy the entire addons/pythonscript/<platform>
directory to the target
3) the plugin should also copy the python files and keep their paths intact. This is needed given we use the regular python import system to load python scripts (currently the the .py file end up in the .pck export file just like the .gd, but python doesn't know about .pck file so the import fails)
4) in theory we should also prevent the .py files to end up in the .pck file. I guess it's not technically very important given as I said Python doesn't know about .pck files, but it maybe important for Godot not to have a given .py file in two different places (on the disk and inside the .pck)
Notes:
Compiling to .pyc
is as easy as python -m compileall .
- assuming that python is part of the system $PATH
and you want to compile the present folder. Please, please, please - Defer to the above, just be aware it's removed to aim at a lower reasonable branch for compilation here.
Putting this here because I looked into it wondering.
Hi @gustavi !
I've started working on this issue a couple of weeks ago, but I have put it on hold to focus on a better plugin install&update experience (the assetlib is not well suited for big platform-dependent project such as this one), this should allow me to do much more frequent release so I consider it should come first ;-)
Considering what should be done for the export: 1) create an export plugin (using the PluginEditor.add_export_plugin) 2) during export, the plugin should copy the entire
addons/pythonscript/<platform>
directory to the target 3) the plugin should also copy the python files and keep their paths intact. This is needed given we use the regular python import system to load python scripts (currently the the .py file end up in the .pck export file just like the .gd, but python doesn't know about .pck file so the import fails) 4) in theory we should also prevent the .py files to end up in the .pck file. I guess it's not technically very important given as I said Python doesn't know about .pck files, but it maybe important for Godot not to have a given .py file in two different places (on the disk and inside the .pck)Notes:
- we could hook into the python loading mechanism to make it understand .pck files (hence 3 would no longer be needed), but it is probably more complicated to do and it wouldn't work for binary modules (typically when using cython in the project).
- we could also turn the .py into .pyc during the build phase, but I think it's better to ignore this for the moment in order to keep things simple
- an additional good feature we be to allow user to plug a hook function into the export/build system so that he could automate some tasks such has cython compilation
Hi @touilleMan
First of all thanks for making such a powerful thing but while developing a game in Godot with python I encountered the issue for export so I am willing to help๐๐
I am very much interested in making this and know how to make plugins for Godot and also I go through the link you shared I am willing to work explain me more and I will get going.
Hi @gustavi !
I've started working on this issue a couple of weeks ago, but I have put it on hold to focus on a better plugin install&update experience (the assetlib is not well suited for big platform-dependent project such as this one), this should allow me to do much more frequent release so I consider it should come first ;-)
Considering what should be done for the export: 1) create an export plugin (using the PluginEditor.add_export_plugin) 2) during export, the plugin should copy the entire
addons/pythonscript/<platform>
directory to the target 3) the plugin should also copy the python files and keep their paths intact. This is needed given we use the regular python import system to load python scripts (currently the the .py file end up in the .pck export file just like the .gd, but python doesn't know about .pck file so the import fails) 4) in theory we should also prevent the .py files to end up in the .pck file. I guess it's not technically very important given as I said Python doesn't know about .pck files, but it maybe important for Godot not to have a given .py file in two different places (on the disk and inside the .pck)Notes:
- we could hook into the python loading mechanism to make it understand .pck files (hence 3 would no longer be needed), but it is probably more complicated to do and it wouldn't work for binary modules (typically when using cython in the project).
- we could also turn the .py into .pyc during the build phase, but I think it's better to ignore this for the moment in order to keep things simple
- an additional good feature we be to allow user to plug a hook function into the export/build system so that he could automate some tasks such has cython compilation
Hi @touilleMan
First of all thanks for making such a powerful thing but while developing a game in Godot with python I encountered the issue for export so I am willing to help๐๐
I am very much interested in making this and know how to make plugins for Godot and also I go through the link you shared I am willing to work explain me more and I will get going.
Helpful if you can guide Thanks
@Harshharsh2275 not sure what more I can provide on this topic. If you want to work on this topic Iย suggest you start by creating a simple export plugin that gets called when the export starts, from this on we can iterate over to add tings step by step ;-)
I'm currently working on this issue. I'll post update in following hours/days when it starts working.
First of all, thanks so much for the incredibly amazing project that is godot-python
.
Today I spent some time trying automated build system to work by starting with your suggested steps @touilleMan :
- create an export plugin (using the PluginEditor.add_export_plugin)
- during export, the plugin should copy the entire
addons/pythonscript/<platform>
directory to the target- the plugin should also copy the python files and keep their paths intact. This is needed given we use the regular python import system to load python scripts (currently the the .py file end up in the .pck export file just like the .gd, but python doesn't know about .pck file so the import fails)
- in theory we should also prevent the .py files to end up in the .pck file. I guess it's not technically very important given as I said Python doesn't know about .pck files, but it maybe important for Godot not to have a given .py file in two different places (on the disk and inside the .pck)
I ended up being successful by making and using a custom build template. In case anyone else out there is stuck while waiting for full support from @gustavi , I added the more detailed instructions to a Gist. If there's anything I can assist with or you have a working branch @gustavi let me know.
For now, I'm essentially copying all project files in .py
into the archive after export. This has drawbacks, of course, but it's the simplest automated workflow I could come up with.
Once it's done, it's pretty simple to just add the build templates in the UI:
No news for a while here, I was really busy at work + holidays.
@omardelarosa your solution is really interesting, more than mine by far. I'll try to port it on my computers (Windows 10 / ArchLinux) and keep you in touch.
@gustavi Can you share any help on windows? Thanks
Any updates about this ? @touilleMan @gustavi
Not at all, onyl dirty hacks for my own computer. I'm not working on this issue anymore sorry.
Anyone has a solution for Windows using the pck?@touilleMan
May I ask how to encrypt the material resources of the game?
May I ask how to encrypt the material resources of the game?
Yes, but you're not at the good place: https://github.com/touilleMan/godot-python/discussions
Any ground made here? It just absolutely refuses to acknowledge the DLL even exists
Currently there is no automating support for the build system.
What this means is exporting a project using godot-python result in a .pck/zip file which lacks the pythonscript directory (well from my tests, the pythonscript directory is present, but only contain some image that should have been found by Godot's generic export system...)
So right now exporting a project means you have to:
And then you have a directory that can run the project fine.
Least we can say is...this is far from ideal :/