distutils and inplace build: is numpy supposed to work ?

Hi, I wanted to know if numpy was supposed to work when built in place through the -i option of distutils. The reason why I am asking it that I would like to support it in numscons, and I cannot make it work when using distutils. Importing numpy works in the source tree, but most tests fail because of some missing imports; I have a lots of those: ====================================================================== ERROR: Check that matrix type is preserved. ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/media/src/dsp/numpy/trunk/numpy/linalg/tests/test_linalg.py", line 69, in test_matrix_a_and_b self.do(a, b) File "/usr/media/src/dsp/numpy/trunk/numpy/linalg/tests/test_linalg.py", line 99, in do assert_almost_equal(a, dot(multiply(u, s), vt)) File "/usr/media/src/dsp/numpy/trunk/numpy/linalg/tests/test_linalg.py", line 22, in assert_almost_equal old_assert_almost_equal(a, b, decimal=decimal, **kw) File "numpy/testing/utils.py", line 171, in assert_almost_equal from numpy.core import ndarray File "core/__init__.py", line 27, in <module> __all__ += numeric.__all__ NameError: name 'numeric' is not defined Is this expected, or am I doing something wrong ? cheers, David

On Thu, Jul 31, 2008 at 8:18 AM, David Cournapeau < david@ar.media.kyoto-u.ac.jp> wrote:
Hi,
I wanted to know if numpy was supposed to work when built in place through the -i option of distutils. The reason why I am asking it that I would like to support it in numscons, and I cannot make it work when using distutils. Importing numpy works in the source tree, but most tests fail because of some missing imports; I have a lots of those:
Robert made some fixes to support in place builds, so if it doesn't work, it's probably a bug. Chuck

On Thu, Jul 31, 2008 at 09:18, David Cournapeau <david@ar.media.kyoto-u.ac.jp> wrote:
Hi,
I wanted to know if numpy was supposed to work when built in place through the -i option of distutils. The reason why I am asking it that I would like to support it in numscons, and I cannot make it work when using distutils. Importing numpy works in the source tree, but most tests fail because of some missing imports; I have a lots of those:
====================================================================== ERROR: Check that matrix type is preserved. ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/media/src/dsp/numpy/trunk/numpy/linalg/tests/test_linalg.py", line 69, in test_matrix_a_and_b self.do(a, b) File "/usr/media/src/dsp/numpy/trunk/numpy/linalg/tests/test_linalg.py", line 99, in do assert_almost_equal(a, dot(multiply(u, s), vt)) File "/usr/media/src/dsp/numpy/trunk/numpy/linalg/tests/test_linalg.py", line 22, in assert_almost_equal old_assert_almost_equal(a, b, decimal=decimal, **kw) File "numpy/testing/utils.py", line 171, in assert_almost_equal from numpy.core import ndarray File "core/__init__.py", line 27, in <module> __all__ += numeric.__all__ NameError: name 'numeric' is not defined
Is this expected, or am I doing something wrong ?
I have been running numpy built inplace for a long time now. As far as I can tell, this only shows up when running numpy.test() while in the numpy trunk checkout directory. I think it's an interaction with the way nose traverses packages to locate tests. numpy/core/__init__.py is a bit odd; it does "from numeric import *" and expects "numeric" to then be in the namespace. I think this only happens when the import machinery knows that it's in a package. nose uses __import__() when scouting around the package, so it misses this. For example, [~]$ ls foo __init__.py bar.py [~]$ cat foo/__init__.py from bar import x print dir() print bar.x [~]$ cat foo/bar.py x = 1 [~]$ python -c "import foo" ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'bar', 'x'] 1 [~]$ python -c "__import__('foo.__init__')" ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'bar', 'x'] 1 ['__builtins__', '__doc__', '__file__', '__name__', 'x'] Traceback (most recent call last): File "<string>", line 1, in <module> File "foo/__init__.py", line 3, in <module> print bar.x NameError: name 'bar' is not defined -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (3)
-
Charles R Harris
-
David Cournapeau
-
Robert Kern