This is not a duplicate of the question:
Import python packages with different versions installed
Nor can it be solved by virtualenv/pipenv: packages that share the same name/path but has different code/version must be installed under the same environment for the program to function properly
Considering the following classic diamond dependency problem:
- program <- feature_A <- library (v 1.0)
- program <- feature_B <- library (v 2.0)
Assuming we have full access over the sourcecode of packages 'program', 'feature_A', and 'feature_B', and both feature_A and feature_B has the following code:
import library.*
In a conventional package manager like virtualenv, pip and conda, The above situation will preclude feature_A and feature_B from being used in the same project. However since python is an interpretive language, and we can use the source code of feature_A and feature_B. It should be possible to do the following things:
-
ingest the package source/byte codes of both
library (v1.0)
andlibrary (v2.0)
, generate 2 cryptographic hash for each, and install them under 2 different paths that depends on their respective hashes. -
use a code generator to rewrite
feature_A
andfeature_B
such that they import from new paths that depends on cryptographic hashes, and install the rewritten versions. -
use the code generator to rewrite
program
such that it imports from the new paths where the rewrittenfeature_A
andfeature_B
are installed.
Now my question is: how difficult it is to fully automate this process? Is a weak artificial intelligence required? Or it can be accomplished using pure functional logic?
from How to import a package with a specific version?
No comments:
Post a Comment