Hacker News new | ask | show | jobs
by yorwba 20 days ago
Python's import system is extensible: 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...
1 comments

Yep that's pretty much how I do it, along with RPyC[0] for connection.

[0] https://rpyc.readthedocs.io/en/latest/