When using python code in renpy game, all modules in a package which is then places in the game directory must use package.module expression when importing, even if its local import. This is not how should importing work at all...
Moreover, only .py files will get loaded from game directory, not pyo nor pyc. So fix is to move them to renpy/ directory, but there, the importing is correct and package.module imports do not work anymore.
I think the need for package.module whenever the py files are used in game directory is a bug. And not working with pyc/pyo is bug as well.
Bug on loading modules / Bug on loading pyc/pyo from game
-
- Miko-Class Veteran
- Posts: 616
- Joined: Thu Oct 26, 2006 4:23 pm
- Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
- Location: Slovakia, Kosice
- Contact:
Bug on loading modules / Bug on loading pyc/pyo from game
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Bug on loading modules / Bug on loading pyc/pyo from gam
Do you have an example of how I can repeat this?Enerccio wrote:When using python code in renpy game, all modules in a package which is then places in the game directory must use package.module expression when importing, even if its local import. This is not how should importing work at all...
You really shouldn't distribute game code as a pyo or pyc file. If your game is run under a newer version of Ren'Py (for example, a version that uses Python 2.7), it will stop working if it can't recompile the pyo or pyc files.Moreover, only .py files will get loaded from game directory, not pyo nor pyc. So fix is to move them to renpy/ directory, but there, the importing is correct and package.module imports do not work anymore.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Miko-Class Veteran
- Posts: 616
- Joined: Thu Oct 26, 2006 4:23 pm
- Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
- Location: Slovakia, Kosice
- Contact:
Re: Bug on loading modules / Bug on loading pyc/pyo from gam
Hmm, found another bug, at least for me, if I want to load empty .py file, I get error on this line:
(loader.py 474)
Obviously, since empty file has no text, and having empty __init__.py is very common
Code: Select all
source = load(filename).read().decode("utf8")
if source[0] == u'\ufeff':
Obviously, since empty file has no text, and having empty __init__.py is very common
Why is that an issue? Obviously we are not gonna store pyc files, we are only going to use them for the release. And people should not update renpy on their games as far as I know.PyTom wrote:Enerccio wrote:You really shouldn't distribute game code as a pyo or pyc file. If your game is run under a newer version of Ren'Py (for example, a version that uses Python 2.7), it will stop working if it can't recompile the pyo or pyc files.Moreover, only .py files will get loaded from game directory, not pyo nor pyc. So fix is to move them to renpy/ directory, but there, the importing is correct and package.module imports do not work anymore.
- Attachments
-
- f.rar
- This wont work
- (41.64 KiB) Downloaded 51 times
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU
-
- Miko-Class Veteran
- Posts: 616
- Joined: Thu Oct 26, 2006 4:23 pm
- Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
- Location: Slovakia, Kosice
- Contact:
Re: Bug on loading modules / Bug on loading pyc/pyo from gam
This is still not fixed?
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Bug on loading modules / Bug on loading pyc/pyo from gam
Relative imports should work, although absolute imports are preferred. And the \xfeff code only works for non-empty files.
We only support .py files, and not .pyc/.pyo files. This is because the version of Python bundled with Ren'Py can change, and that can cause compatibility problems with older bytecode files. To avoid this, Ren'Py only loads .pys.
We only support .py files, and not .pyc/.pyo files. This is because the version of Python bundled with Ren'Py can change, and that can cause compatibility problems with older bytecode files. To avoid this, Ren'Py only loads .pys.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Miko-Class Veteran
- Posts: 616
- Joined: Thu Oct 26, 2006 4:23 pm
- Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
- Location: Slovakia, Kosice
- Contact:
Re: Bug on loading modules / Bug on loading pyc/pyo from gam
That makes no sense, if so, why do you support reading rpyc files? It's same deal (or are they completely backwards compatible?). User should not change version of python for a released game. Not only that, but loading pyo (and pyo only, not pyc) works if I move the library from game into root, which again makes no sense. Why not just read pyo from everywhere. Btw I am talking about custom library not renpy code. Also, in what world would make sense to change python from already released game?
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU
Who is online
Users browsing this forum: No registered users