The structure of the PETSc installation makes it possible to install different versions and different configurations side by side. You can choose which one you want to work with at run time (or build time) using PETSC_DIR, choosing between real and complex number support, for instance.
Is it feasible to maintain a similar kind of concurrent installation for petsc4py? Installation of the modules themselves could be easy, e.g. rename as /usr/lib/python3/dist-packages/petsc4py_real and petsc4py_complex, perhaps provide petsc4py as a symlink to the preferred configuration. Then each of "import petsc4py_real", "import petsc4py_complex", "import petsc4py" would run in python.
But then the internals of the module still refer to petsc4py. So while "import petsc4py_complex" will present get_config(), get_include() and init(), and petsc4py_complex.init() will run without error, at the same time it does not load up petsc4py_complex.PETSc.
So only "import petsc4py" runs correctly, though its petsc configuration can be switched by swapping a petsc4py symlink in the python module dir between petsc4py_real and petsc4py_complex.
Would there be a straightforward way of activating petsc4py_real and petsc4py_complex modules so that different configurations can be used by different python applications (one might use
import petsc4py_complex as petsc4py for instance) at the same time?