[Numpy-discussion] Controlling the way a module is imported
Mon May 26 15:21:00 CDT 2008
David, I've implemented something like this for petsc4py.
Basically, I want to be able to build extension modules accessing
PETSc for different configuration options (for example, optimized
versus debug), when using PETSc, it is normal to select the build
variant by a $PETSC_ARCH environ var.
All this is implemented in pure Python code, and tanking advantage of
the built-in 'imp' module. I believe it is robust enough, I had never
received any report of this causing trouble from petsc4py users out
If you think this fits your needs, then I'll help you. Buth then I'll
need to know a bit more about the directory tree structure of your
package and your extension modules.
On 5/25/08, David Cournapeau <email@example.com> wrote:
> This is not numpy specific, but I need it for numpy/scipy. More
> specifically, I would like to be able to have one module interface which
> load imp1, imp2, imp3, etc... depending on some options. I see two
> obvious solutions: monkey patching, and file configuration, but I try to
> avoid the former, and there is no mechanism for the later in scipy. I
> read that import hooks could be used for this purpose, but I don't quite
> understand the pep:
> Has anyone played with it ?
> Numpy-discussion mailing list
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
More information about the Numpy-discussion