3 ms·
Python's import system is extensible: https://docs.python.org/3/reference/import.html#import-hooks https://docs.python.org/3/reference/import.html#import-hooks
by yorwba 5mo ago
Python's import system is extensible: https://docs.python.org/3/reference/import.html#import-hooks https://docs.python.org/3/reference/import.html#import-hooks It might be possible to create a custom finder that will return 1.0.0 when running "import dependency_c" in dependency_a but 2.0.0 for the same import statement in dependency_b. You'll need to work around the module cache in sys.modules, though. And good luck trying this on a package that also hooks the import system...
- skeledrew 5mo agoYep that's pretty much how I do it, along with RPyC[0] for connection. [0] https://rpyc.readthedocs.io/en/latest/ https://rpyc.readthedocs.io/en/latest/