Building With Dynmically-Imported Modules

Hmm… That seems to help indeed–thank you! :slight_smile:

But it also seems to means that the VFS can no longer discover the module (presumably because it’s frozen into the executable).

(I want the VFS to be able to see it in order to detect the presence of such secondary modules. Building them into executable isn’t my long-term intent–I want them to be located in separate “.mf” files eventually–but seemed like a potential short-term solution to making a demo.)

Hmm… That does look like it might be worth investigating, thank you. :slight_smile:

[edit 3]
Hmm… Looking briefly at the Python API on the matter, it looks like the module that you mention is more intended for non-code resources, while the main of my problem is with the dynamic importation of code.
[/edit 3]

[edit]
Perhaps it would help for me to explain less-abstractly (if still in broad strokes) what I’m attempting to do:

At the root, I have the “core” of the game, where I have implemented all of the game’s base logic–movement, player-handling, scenes, etc.

But I want specific game-elements to be modular, allowing not only the “default adventure”, but potentially others, too. To this end, there is a sub-folder named “Content” (“<Sub-dir1>”, above), which in turn contains sub-folders for each individual “adventure”.

Note that these sub-directories contain not only assets, but Python code too–classes for specific enemies and items, for example. Naturally, these inherit from base-classes found in the “game-core”.

(In the long run I want these modules to be held within multifiles–but as shown in another thread, that comes with its own complications…)

The “core” then uses the VFS to scan the “Content” directory, looking for modules to potentially make use of (via importation).

Hence my problem: Freezing these modules (aside from making them no longer modular) prevents the VFS from finding them; but if I simply have them be copied into place, they can no longer import from their frozen base-modules…

[edit 2]
As a fallback position for the purposes of my initial demo, if called for I daresay that I can comment-out the dynamic importation and just statically import the current secondary module. I’d rather not, but it would allow me to move forward, at least.

Still, should the project keep going I would presumably eventually want a solution…