I’m struggling a little to produce a working distributable build in a game that dynamically imports certain elements.
Specifically, I have a development file structure that looks something like this:
<Root-dir>
|___ <Sub-dir>
| |
| |__ "__init__.py"
| |
| |_____<Sub-dir 2>
| |
| |__ "__init__.py"
| |
| |__ secondary module (Python scripts, sub-directories, assets, etc.)
|
|
|__ main program files (Python scripts, sub-directories, assets, etc.)
The main program, located in the root directory, dynamically discovers (via the VFS) and imports the secondary module, located in a sub-directory of a sub-directory. During development, this works as expected.
However, when I make a distributable build, things become more complicated: Naturally, the dynamically-imported module isn’t automatically detected during the build, and thus isn’t included in it.
My attempts to make use of the “include_modules” build-option have thus far failed–and I’ve used a number of values, including “<Sub-dir1>”, “<Sub-dir1>.*”, and “<Sub-dir1>.<Sub-dir2>.*”.
I’ve also tried just adding “<Sub-dir1>” to “include_patterns”, hoping to simply copy the whole thing in and have it be imported as in the development version. Here, the importation works–but it seems that the secondary module is then unable to import any modules from the main directory. :/
(That is, the following no longer works: Assume that within the root directory itself, there is a Python file named “Cat.py”. Assume further that within <Sub-dir2> there is a Python file named “Kitten.py”. During development, having “Kitten.py” import from “Cat.py” works–but in the built version it no longer does.)
Does anyone know where I might be going wrong, and how I might gain a working distributable build with the structure that I have…?