[Numpy-discussion] Function numpy.get_include() has a side effet
Nicolas Grilly
nicolas.grilly@garden-paris....
Fri Feb 9 21:11:45 CST 2007
Hello,
I have a package with a distutils script. This script calls
numpy.get_include(), in order to get numpy's header files location.
But the function seems to have a side effect by silently patching
distutils. Some classes and functions of standard library distutils
are replaced by numpy's ones.
For example, before calling numpy.get_include(), the function
new_compiler comes from standard library:
>>> from distutils.ccompiler import new_compiler
>>> new_compiler.__module__
'distutils.ccompiler'
But after calling numpy.get_include(), the function comes from numpy:
>>> import numpy
>>> numpy.get_include()
>>> from distutils.ccompiler import new_compiler
>>> new_compiler.__module__
'numpy.distutils.ccompiler'
This is because the code of numpy.get_include() imports
numpy.distutils, and this triggers the patching mechanism.
This is a problem because the behavior of distutils is different
before and after the call to numpy.get_include(), and it breaks my
distutils script.
Is it possible to remove this side effect?
Thanks,
Nicolas Grilly
More information about the Numpy-discussion
mailing list