Re: [Numpy-discussion] distutils issue - python 3.1 on windows
On Wed, Aug 4, 2010 at 6:25 AM, Pauli Virtanen p...@iki.fi wrote: Mon, 02 Aug 2010 23:48:52 +0800, Ralf Gommers wrote: I'm trying to get building to work with Python 3.1 under Wine on OS X. The first thing you run into is a python distutils problem, which is fixed by replacing line 379 of cygwinccompiler.py with result = RE_VERSION.search(str(out_string)) Ah yep, cygwinccompiler.py is in Python's distutils, I wondered for a while where the bug was :) But actually, I'm now looking at the cygwinccompiler.py source code, and to me it seems it should be ok. The RE_VERSION is a byte-regular expression, so it's not obvious why making the input a str would help? I haven't started using py3k yet so I'm still a bit fuzzy about bytes vs string. But it's easy to try in the interpreter: import re RE_VERSION = re.compile('(\d+\.\d+(\.\d+)*)') cmd = gcc -dumpversion from subprocess import Popen, PIPE out = Popen(cmd, shell=True, stdout=PIPE).stdout out_string = out.read() out.close() result = RE_VERSION.search(out_string) Traceback (most recent call last): File stdin, line 1, in module TypeError: can't use a string pattern on a bytes-like object File Z:\Users\rgommers\Code\numpy\build\py3k\numpy\distutils \mingw32ccompiler.py, line 177, in link func(*args[:func.__func__.__code__.co_argcount]) AttributeError: 'function' object has no attribute '__func__' I fixed this in trunk r8595 (cherry-pick to 1.5.x if you find it works). That works, thanks. Then there's was still one more problem, _dotblas.c was not py3k ready. With this fix I can build everything under Wine: http://github.com/rgommers/numpy/tree/build-py3k Does that look fine? Cheers, Ralf ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] distutils issue - python 3.1 on windows
Wed, 04 Aug 2010 23:34:15 +0800, Ralf Gommers wrote: [clip] I haven't started using py3k yet so I'm still a bit fuzzy about bytes vs string. But it's easy to try in the interpreter: import re RE_VERSION = re.compile('(\d+\.\d+(\.\d+)*)') In the Python 3.1 version I have, this line reads RE_VERSION = re.compile(b'(\d+\.\d+(\.\d+)*)') which makes it a byte-regular expression. [clip] That works, thanks. Then there's was still one more problem, _dotblas.c was not py3k ready. Doh! How did I miss that (answer: no tests, and the import error is masked :) With this fix I can build everything under Wine: http://github.com/rgommers/numpy/tree/build-py3k Does that look fine? It compiles, but will probably crash on import :) You need also to return the module object, see e.g. how it's done in numpy/numarray/_capi.c I committed a fixed version. Cheers, Pauli ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] distutils issue - python 3.1 on windows
Mon, 02 Aug 2010 23:48:52 +0800, Ralf Gommers wrote: I'm trying to get building to work with Python 3.1 under Wine on OS X. The first thing you run into is a python distutils problem, which is fixed by replacing line 379 of cygwinccompiler.py with result = RE_VERSION.search(str(out_string)) Ah yep, cygwinccompiler.py is in Python's distutils, I wondered for a while where the bug was :) But actually, I'm now looking at the cygwinccompiler.py source code, and to me it seems it should be ok. The RE_VERSION is a byte-regular expression, so it's not obvious why making the input a str would help? File Z:\Users\rgommers\Code\numpy\build\py3k\numpy\distutils \mingw32ccompiler.py, line 177, in link func(*args[:func.__func__.__code__.co_argcount]) AttributeError: 'function' object has no attribute '__func__' I fixed this in trunk r8595 (cherry-pick to 1.5.x if you find it works). Pauli ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] distutils issue - python 3.1 on windows
Mon, 02 Aug 2010 23:48:52 +0800, Ralf Gommers wrote: I'm trying to get building to work with Python 3.1 under Wine on OS X. The first thing you run into is a python distutils problem, which is fixed by replacing line 379 of cygwinccompiler.py with result = RE_VERSION.search(str(out_string)) That's going to bust when out_string contains stuff that does not fit in ASCII. I don't remember how this was addressed in the rest of distutils. The next thing I run into is a numpy.distutils issue (complete build output below email): File Z:\Users\rgommers\Code\numpy\build\py3k\numpy\distutils \mingw32ccompiler.py, line 177, in link func(*args[:func.__func__.__code__.co_argcount]) AttributeError: 'function' object has no attribute '__func__' What I think that line is for is to test what kind of arguments can be passed to 'func', but I'm really not sure. A comment would have been helpful, that must be the most obscure line of Python code I've ever seen:) Does anyone have any idea what causes this error? This is change in the code object internals in Python 3, and 2to3 doesn't seem able make the conversions automatically. I don't remember exactly how it goes, but there are other instances of this in Numpy -- need to do one thing on Python 2 and another on Python 3. Anyway, here it seems like the `inspect` module should be used -- no need to go mucking with in the code objects to just find the number of arguments for a function. Nobody has tested this part of the distutils code on Python 3, and indeed it does not have any tests, so it's not a surprise that stuff like this is left over :) -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] distutils issue - python 3.1 on windows
On Mon, Aug 2, 2010 at 12:48, Pauli Virtanen p...@iki.fi wrote: Mon, 02 Aug 2010 23:48:52 +0800, Ralf Gommers wrote: I'm trying to get building to work with Python 3.1 under Wine on OS X. The first thing you run into is a python distutils problem, which is fixed by replacing line 379 of cygwinccompiler.py with result = RE_VERSION.search(str(out_string)) That's going to bust when out_string contains stuff that does not fit in ASCII. I don't remember how this was addressed in the rest of distutils. The next thing I run into is a numpy.distutils issue (complete build output below email): File Z:\Users\rgommers\Code\numpy\build\py3k\numpy\distutils \mingw32ccompiler.py, line 177, in link func(*args[:func.__func__.__code__.co_argcount]) AttributeError: 'function' object has no attribute '__func__' What I think that line is for is to test what kind of arguments can be passed to 'func', but I'm really not sure. A comment would have been helpful, that must be the most obscure line of Python code I've ever seen:) Does anyone have any idea what causes this error? This is change in the code object internals in Python 3, and 2to3 doesn't seem able make the conversions automatically. I don't remember exactly how it goes, but there are other instances of this in Numpy -- need to do one thing on Python 2 and another on Python 3. Anyway, here it seems like the `inspect` module should be used -- no need to go mucking with in the code objects to just find the number of arguments for a function. Nobody has tested this part of the distutils code on Python 3, and indeed it does not have any tests, so it's not a surprise that stuff like this is left over :) I believe we avoided the inspect module because it is quite expensive to import. It may not matter inside numpy.distutils, but be wary of fixing things to use inspect elsewhere. It would be worth extracting the commonly-used pieces of inspect (and hacks like this) into an internal utility module that is fast to import. -- 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 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] distutils issue - python 3.1 on windows
Mon, 02 Aug 2010 12:52:12 -0500, Robert Kern wrote: [clip] I believe we avoided the inspect module because it is quite expensive to import. It may not matter inside numpy.distutils, but be wary of fixing things to use inspect elsewhere. It would be worth extracting the commonly-used pieces of inspect (and hacks like this) into an internal utility module that is fast to import. We actually have `numpy.compat._inspect` and from numpy.compat import getargspec that could be used here. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] distutils issue - python 3.1 on windows
On 08/03/2010 02:57 AM, Pauli Virtanen wrote: Mon, 02 Aug 2010 12:52:12 -0500, Robert Kern wrote: [clip] I believe we avoided the inspect module because it is quite expensive to import. It may not matter inside numpy.distutils, but be wary of fixing things to use inspect elsewhere. It would be worth extracting the commonly-used pieces of inspect (and hacks like this) into an internal utility module that is fast to import. We actually have `numpy.compat._inspect` and from numpy.compat import getargspec that could be used here. Yep, it was added precisely for avoiding the slow import of upstream inspect, cheers, David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion