Is there a workaround for the version conflict issue caused by Pyxb

I have 3 python projects. Project A, Project B and Project C. Project C depends on Porject A and B

Project C --- depends ---> Project A
Project C --- depends ---> Project B

      

Both project A and project B depend on PyXB , they use some generated schema module. Unfortunately project A uses PyXB 1.2.2 and project B uses PyXB 1.2.3

Project A --- depends ---> PyXB 1.2.2
Project B --- depends ---> PyXB 1.2.3

      

If you read these modules, you will see

# 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)

      

and

# 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)

      

So at the moment Project C has a version issue issue

Project C --- depends ---> PyXB 1.2.2
                                ^
                                |
                                X conflict
                                |
                                v
Project C --- depends ---> PyXB 1.2.3

      

And since these schema modules have been manually modified. It is difficult to regenerate them and apply the same modifications. So I'm wondering if it is possible to import the same module with a different version in Python. For example, I am guessing it might be something like

with import_routing('pyxb', '..packages.pyxb1_2_3'):
    import project_a

      

Is there such a tool? or is there any other workaround that I can use in this situation?

+3


source to share


1 answer


Not easy. The links do make assumptions about the underlying API represented by a specific version of PyXB. There is probably some magic you could do with modifying the module's metadata to allow the two versions to coexist if neither document references bindings from both namespaces.



It is unfortunate that the generated bindings were manually changed. In many cases, using the PyXB customization framework removes that tight coupling, in which case you can re-create the bindings and reuse the settings that overlap them.

+1


source







All Articles