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

Export system #146

Open
touilleMan opened this issue Feb 3, 2020 · 19 comments
Open

Export system #146

touilleMan opened this issue Feb 3, 2020 · 19 comments

Comments

@touilleMan
Copy link
Owner

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:

  • export in .zip format
  • extract the .zip in a directory
  • add the godot release (preferably the one from the Godot export templates) binary to this directory

And then you have a directory that can run the project fine.

Least we can say is...this is far from ideal :/

@bestdani
Copy link

bestdani commented May 22, 2020

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.

@greysondn
Copy link

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?"

@touilleMan
Copy link
Owner Author

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.

@gustavi
Copy link

gustavi commented Oct 10, 2020

This issue is really interesting for me. If you have some idea for a real export I could help.

@touilleMan
Copy link
Owner Author

touilleMan commented Oct 10, 2020

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

@greysondn
Copy link

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.

@Harshharsh2275
Copy link

Harshharsh2275 commented Oct 11, 2020

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.

@Harshharsh2275
Copy link

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

@touilleMan
Copy link
Owner Author

@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 ;-)

@gustavi
Copy link

gustavi commented Nov 22, 2020

I'm currently working on this issue. I'll post update in following hours/days when it starts working.

@omardelarosa
Copy link

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 :

  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)

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:

gui_build_path

@gustavi
Copy link

gustavi commented Jan 13, 2021

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.

@vmjcv
Copy link

vmjcv commented Feb 23, 2021

@gustavi Can you share any help on windows? Thanks

@Andrea-Miele
Copy link

Andrea-Miele commented May 20, 2021

Any updates about this ?
@touilleMan @gustavi

@gustavi
Copy link

gustavi commented May 21, 2021

Not at all, onyl dirty hacks for my own computer. I'm not working on this issue anymore sorry.

@Andrea-Miele
Copy link

Anyone has a solution for Windows using the pck?@touilleMan

@529124368
Copy link

May I ask how to encrypt the material resources of the game?

@gustavi
Copy link

gustavi commented Sep 26, 2022

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

@Lance-Starkie
Copy link

Any ground made here? It just absolutely refuses to acknowledge the DLL even exists

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

No branches or pull requests

10 participants