[Numpy-discussion] ANN: Numpy 1.6.1 release candidate 1

Bruce Southey bsouthey at gmail.com
Mon Jun 13 23:28:11 EDT 2011


On Mon, Jun 13, 2011 at 8:31 PM, Pauli Virtanen <pav at iki.fi> wrote:
> On Mon, 13 Jun 2011 11:08:18 -0500, Bruce Southey wrote:
> [clip]
>> OSError:
>> /usr/local/lib/python3.2/site-packages/numpy/core/multiarray.pyd: cannot
>> open shared object file: No such file or directory
>
> I think that's a result of Python 3.2 changing the extension module
> file naming scheme (IIRC to a versioned one).
>
> The '.pyd' ending and its Unix counterpart are IIRC hardcoded to the
> failing test, or some support code in Numpy. Clearly, they should instead
> ask Python how it names the extensions modules. This information may be
> available somewhere in the `sys` module.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

Pauli,
I am impressed yet again!
It really saved a lot of time to understand the reason.

A quick comparison between Python versions:
Python2.7: multiarray.so
Python3.2:  multiarray.cpython-32m.so

Search for the extension leads to PEP 3149
http://www.python.org/dev/peps/pep-3149/

This is POSIX only which excludes windows. I tracked it down to the
list 'libname_ext' defined in file "numpy/ctypeslib.py"  line 100:
libname_ext = ['%s.so' % libname, '%s.pyd' % libname]

On my 64-bit Linux system, I get the following results:
$ python2.4 -c "from distutils import sysconfig; print
sysconfig.get_config_var('SO')"
.so
$ python2.5 -c "from distutils import sysconfig; print
sysconfig.get_config_var('SO')"
.so
$ python2.7 -c "from distutils import sysconfig; print
sysconfig.get_config_var('SO')"
.so
$ python3.1 -c "from distutils import sysconfig;
print(sysconfig.get_config_var('SO'))"
.so
$ python3.2 -c "from distutils import sysconfig;
print(sysconfig.get_config_var('SO'))"
.cpython-32m.so

My Windows 32-bit Python2.6  install:
>>> from distutils import sysconfig
>>> sysconfig.get_config_var('SO')
'.pyd'

Making the bug assumption that other OSes including 32-bit and 64-bit
versions also provide the correct suffix, this suggest adding the
import and modification as:

import from distutils import sysconfig
libname_ext = ['%s%s' % (libname, sysconfig.get_config_var('SO'))]

Actually if that works for Mac, Sun etc. then 'load_library' function
could be smaller.

Finally the test_basic2 in "tests/test_ctypeslib.py" needs to be
changed as well because it is no longer correct. Just commenting out
the 'fix' appears to work.

Bruce



More information about the NumPy-Discussion mailing list