Open mzwaal opened 1 month ago
This project links with neither Godot or godot-cpp, nor does it need to. It uses the APIs defined in gdextension_interface.h
and generates the remaining bindings dynamicly at runtime. This simplifies the bindings, reduces build times and sizes, and allows for greater flexibility.
As for your other question, I haven't gotten around to figuring how integration with any sort of existing package management should work.
The current situation is any pure Python code found within the project directory should just work. There is a project setting to specify res://
paths as additional module search paths if you need to organize things a certain way.
For Python extension modules (numpy for example), the situation is that no specific handing yet exists. For an exported project there should exist the usual site-packages
subdirectory somewhere beside the export. Non-exported may work from within the project directory, but there isn't any export code yet, so you'd have to copy manually.
the usual
site-packages
subdirectory
Will there be possibility to use e.g. pip
to install python packages into site-packages
?
Will there be possibility to use e.g.
pip
to install python packages intosite-packages
?
I'd really like to see something like that working, and I imagine its possible, but investigation would need to be done on how to make it work, including considerations such as multiple platforms and editor vs exported projects.
Does anyone have any insight or suggestions on the matter? At the moment I'm working on finishing up other features and don't have the time to spare to dig into it.
What does it mean to use pip
in this context? Is it not already possible if you create a virtual environment in the project directory?
I do not understand why the file structure is arranged in this way. Why this is distributed as Zip
There are some inconsistencies of the documentation This is the file structure I get from the Github Action Windows artifact
Mechanism
Setting the
GODOT_PYTHON_MODULE_LIB_DIR
environment variable will change where thegodot
module is loaded from.When set to the path of the source
lib
directory, thegodot
module will be loaded from that directory instead of the embedded module archive.
For example, if the project's repository is checked out to
~/src/godot-python-extension
then starting the Godot editor may look like this:GODOT_PYTHON_MODULE_LIB_DIR=~/src/godot-python-extension/lib godot -e
https://github.com/maiself/godot-python-extension/blob/master/lib/godot/__init__.py
[WIP]
I think during Github Action, the embedded module archive. needs to have the proper file structures which include a typical e.g. conda distributed structure that provide e.g. python.exe and pip.exe for package management in the case of Windows
This godot python extension just need to know where to look for site-package folder
The site package folder is independently managed by pip.exe using command line.
Which mean, the user need to unzip the embedded module archive or pip is done through method instead of manual command line pip.exe
OR
https://github.com/touilleMan/godot-python/blob/godot4-meson/scripts/python_distrib.py
Install Windows https://github.com/touilleMan/godot-python/blob/c2f25e451a861e6ea7545fc3e96c9da99dbdb2a9/scripts/python_distrib.py#L215
@GeorgeS2019, please don't copy large portions of code into comments, its a bit distracting from the discussion and doesn't communicate clearly. Smaller snippets and direct links to potions of code, and a description of why you're referencing it will be much more effective. Right now I'm not really sure what you are trying to say.
(Also please be careful, copying code like that could violate terms of the projects you coped from and potentially cause some trouble for you...)
I'm having trouble with the screenshots, as the bright background hurts my eyes (I'm a dark mode only user). If, in the future, you could post such listings as copyable text that would help a lot. The extra formatting is also distracting, but I want to thank you for using collapsible details.
I hope you don't mind, but I made some quick edits to your comments so that I can try to understand better. I've run out of time today, but I'll likely have another look and reply tomorrow.
@hemebond
What does it mean to use pip in this context? Is it not already possible if you create a virtual environment in the project directory?
It likely is (haven't tried it tho), but the issue is the difference between editor and exported versions of projects. In an exported project the entire project directory is bundled into the pck file. For pure python modules that's fine, but any shared libraries wont be loadable by the operating system when bundled that way.
There's also the issue of distributing for multiple platforms. It would be nice if it were possible to list some required packages, and have things pulled into the project automatically, and also selectively for each export platform. I haven't had time to investigate any of this, so I'm not really sure how things will go.
Hi Mai,
Great effort because I am looking to use some Python libraries in project I made.
I have created an cpp extension myself once and used the godotcpp repo as an interface to the Godot objects. I am curious about why you would want link to the actual Godot binary? I believe you can do the same with just using godotcpp .
An example can be found here btw (including some github actions to build):
https://github.com/nathanfranke/gdextension
I am also curious about using a specific Conda environment and copying it to the game project. Would it be as simple as just making a copy and pointing to it?
Cheers!