Is there a possibility to create an overridable script folder for python?
An application embedding python has a script folder that contains the python extension wrapping code and every codefile that builds upon it/other application code, roughly organized in packages.
I would like to add a second folder for custom scripts, so that the first one never needs to be changed after the application is released, and can thus be updated without the risk of killing custom code.
This would be possible just by prepending the custom script folder path to PYTHONPATH, but additionally to the needs described above I would like to be able to override some of the files in the original codebase(selectively), by just copying these files and adjusting them.
My problem then is that if these files do imports on other modules that I don't want to change (and thus don't want to copy), these modules can't be found, which is because I overrode the package as a whole.
I "just" would like to have an approach similar to wrapping a module by doing a
from wrapped_mod import *
def overriden_func(somestuff):
print('overridden function, everything else comes out of wrapped_mod')
Has anyone hints on how to create such "overlay" over an existi开发者_运维技巧ng package hierarchy?
Thanks in advance for ideas!
精彩评论