我有 3 个 python 项目。项目A、项目B和项目C。项目C依赖于项目A和B
Project C --- depends ---> Project A
Project C --- depends ---> Project B
项目 A 和项目 B 都依赖于PyXB,它们使用一些生成的模式模块。不幸的是,项目 A 使用 PyXB 1.2.2,项目 B 使用 PyXB 1.2.3
Project A --- depends ---> PyXB 1.2.2
Project B --- depends ---> PyXB 1.2.3
如果您阅读这些模块,您将看到
# Version of PyXB used to generate the bindings
_PyXBVersion = '1.2.3'
# Generated bindings are not compatible across PyXB versions
if pyxb.__version__ != _PyXBVersion:
raise pyxb.PyXBVersionError(_PyXBVersion)
和
# Version of PyXB used to generate the bindings
_PyXBVersion = '1.2.2'
# Generated bindings are not compatible across PyXB versions
if pyxb.__version__ != _PyXBVersion:
raise pyxb.PyXBVersionError(_PyXBVersion)
因此,目前,项目 C 存在版本冲突问题
Project C --- depends ---> PyXB 1.2.2
^
|
X conflict
|
v
Project C --- depends ---> PyXB 1.2.3
而且由于这些模式模块是手动修改的。很难重新生成它们并应用相同的修改。所以我想知道是否可以在 Python 中导入具有不同版本的相同模块。例如,我设想可能是这样的
with import_routing('pyxb', '..packages.pyxb1_2_3'):
import project_a
有这样的工具吗?或者在这种情况下我可以使用其他解决方法吗?