Re: [Numpy-discussion] porting NumPy to Python 3

Hi Ondrej, To get 2to3 to run without warnings, the following files require minor changes: - numpy/distutils/fcompiler/intel.py - numpy/distutils/misc_util.py - numpy/distutils/command/build_src.py - numpy/f2py/crackfortran.py - numpy/lib/function_base.py - numpy/linalg/lapack_lite/make_lite.py There are also other (possibly many, still working on this) files that require syntactic changes to run post 2to3. Is there anywhere specific I should upload these changes? Is this list appropriate? Is there a developer I can send these and future patches to? James.
Date: Tue, 3 Feb 2009 01:03:15 -0800 From: Ondrej Certik <ondrej@certik.cz> Subject: Re: [Numpy-discussion] porting NumPy to Python 3 To: Discussion of Numerical Python <numpy-discussion@scipy.org> Message-ID: <85b5c3130902030103w69180a6bm4143050b4b82bf1f@mail.gmail.com> Content-Type: text/plain; charset=UTF-8
Hi James,
On Thu, Jan 29, 2009 at 2:11 AM, James Watson <watson.jim@gmail.com> wrote:
Hi,
I am interested in contributing to the port of NumPy to Python 3. Who I should coordinate effort with?
I have started at the Python end of the problem (as opposed to http://www.scipy.org/Python3k), e.g. I have several patches to get 2to3 to work on NumPy's Python source code.
I am sorry that noone has replied to your email. Could you please upload your patches somewhere?
Ondrej

On Wed, Feb 4, 2009 at 10:02 AM, James Watson <watson.jim@gmail.com> wrote:
Hi Ondrej,
To get 2to3 to run without warnings, the following files require minor changes: - numpy/distutils/fcompiler/intel.py - numpy/distutils/misc_util.py - numpy/distutils/command/build_src.py - numpy/f2py/crackfortran.py - numpy/lib/function_base.py - numpy/linalg/lapack_lite/make_lite.py
There are also other (possibly many, still working on this) files that require syntactic changes to run post 2to3.
Is there anywhere specific I should upload these changes? Is this list appropriate? Is there a developer I can send these and future patches to?
Maybe we could add a python 3 milestone so folks could post tickets for these sorts of things. For the time being you could just post to the list here with the patches and something in the subject line that identifies it as a patch for python 3. I think we could make any small changes as long as they are compatible with python 2.4. Chuck

Charles R Harris wrote:
On Wed, Feb 4, 2009 at 10:02 AM, James Watson <watson.jim@gmail.com <mailto:watson.jim@gmail.com>> wrote:
Hi Ondrej,
To get 2to3 to run without warnings, the following files require minor changes: - numpy/distutils/fcompiler/intel.py - numpy/distutils/misc_util.py - numpy/distutils/command/build_src.py - numpy/f2py/crackfortran.py - numpy/lib/function_base.py - numpy/linalg/lapack_lite/make_lite.py
There are also other (possibly many, still working on this) files that require syntactic changes to run post 2to3.
Is there anywhere specific I should upload these changes? Is this list appropriate? Is there a developer I can send these and future patches to?
Maybe we could add a python 3 milestone so folks could post tickets for these sorts of things. For the time being you could just post to the list here with the patches and something in the subject line that identifies it as a patch for python 3. I think we could make any small changes as long as they are compatible with python 2.4.
Chuck
------------------------------------------------------------------------
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
If you follow Guido's recommendation (at the bottom of http://docs.python.org/dev/3.0/whatsnew/3.0.html), then we should first be compatible with Python 2.6 (about the current stage) . Then compatible using Python 2.3 with the -3 flag (warn about Python 3.x incompatibilities) and fix warnings like: numpy/core/__init__.py:11: DeprecationWarning: the cPickle module has been removed in Python 3.0 (Of course you lose speed of cPickle if you blindly change it to use the old Pickle in Python 2.x) Finally use the 2to3 tool to get a Python 3 version. Bruce

I'm taking Chuck and Bruce's suggestions and making sure that the changes are compatible with Python 2.4 and 2.6. I want to make sure diffs are against latest code, but keep getting this svn error: svn update svn: OPTIONS of 'http://scipy.org/svn/numpy/trunk': Could not read status line: Connection reset by peer (http://scipy.org) Am I doing something wrong, or is the server temporarily down? James.
To get 2to3 to run without warnings, the following files require minor changes: - numpy/distutils/fcompiler/intel.py - numpy/distutils/misc_util.py - numpy/distutils/command/build_src.py - numpy/f2py/crackfortran.py - numpy/lib/function_base.py - numpy/linalg/lapack_lite/make_lite.py
If you follow Guido's recommendation (at the bottom of http://docs.python.org/dev/3.0/whatsnew/3.0.html), then we should first be compatible with Python 2.6 (about the current stage) . Then compatible using Python 2.3 with the -3 flag (warn about Python 3.x incompatibilities) and fix warnings like: numpy/core/__init__.py:11: DeprecationWarning: the cPickle module has been removed in Python 3.0 (Of course you lose speed of cPickle if you blindly change it to use the old Pickle in Python 2.x)
Finally use the 2to3 tool to get a Python 3 version.
Bruce
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

2009/2/10 James Watson <watson.jim@gmail.com>: I want to make sure diffs are against latest code, but keep getting this svn error: svn update svn: OPTIONS of 'http://scipy.org/svn/numpy/trunk': Could not read status line: Connection reset by peer (http://scipy.org)
There is some problem at the moment. This seems to be quite common recently, during the very early morning (USA time zones). I guess this is because Murphy's law states that all server problems occur when the admin is trying to get some sleep ;-) Cheers, Scott

2009/2/10 Scott Sinclair <scott.sinclair.za@gmail.com>:
2009/2/10 James Watson <watson.jim@gmail.com>: I want to make sure diffs are against latest code, but keep getting this svn error: svn update svn: OPTIONS of 'http://scipy.org/svn/numpy/trunk': Could not read status line: Connection reset by peer (http://scipy.org)
There is some problem at the moment.
This seems to be quite common recently, during the very early morning (USA time zones).
Note that there is also a git repository available. Clone using git clone --origin svn git://github.com/pv/numpy-svn.git You can always update to the latest version using `git fetch`. Cheers Stéfan

The following are very simple changes that allow the 2to3 program to run on numpy without warnings. Can someone check / commit? numpy/linalg/lapack_lite/make_lite.py: 144c144 < if 'BLAS' in filename ---
if 'BLAS' in filename:
numpy/distutils/misc_util.py: 957c957,958 < map(data_dict[p].add,files) ---
for f in files: data_dict[p].add(f)
983c984,985 < map(self.add_data_files, files) ---
for f in files: self.add_data_files(f)
numpy/distutils/command/build_src.py: 468c468,469 < map(self.mkpath, target_dirs) ---
for td in target_dirs: self.mkpath(td)
635c636,637 < map(self.mkpath, target_dirs) ---
for td in target_dirs: self.mkpath(td)
numpy/f2py/crackfortran.py: 686c686 < raise 'appenddecl: Unknown variable definition key:', k ---
raise Exception('appenddecl: Unknown variable definition key: ' + k)
1545c1545 < raise 'postcrack: Expected block dictionary instead of ',block ---
raise Exception('postcrack: Expected block dictionary instead of ' + block)
numpy/lib/function_base.py: 549c549 < raise 'Internal Shape Error' ---
raise Exception('Internal Shape Error')
These changes are because 1. Python 3 no longer allows string exceptions (http://www.python.org/dev/peps/pep-0352). The recommended method is to use 'except Exception', 2. map has new behaviour, and the 2to3 tool recommends changing simple map calls to for loops, as returning the result of the map is wasteful. Warnings generated by 2to3 on numpy revision 6521: RefactoringTool: Warnings/messages while refactoring: RefactoringTool: ### In file ./numpy/distutils/misc_util.py ### RefactoringTool: Line 957: You should use a for loop here RefactoringTool: Line 983: You should use a for loop here RefactoringTool: ### In file ./numpy/distutils/command/build_src.py ### RefactoringTool: Line 468: You should use a for loop here RefactoringTool: Line 635: You should use a for loop here RefactoringTool: ### In file ./numpy/f2py/crackfortran.py ### RefactoringTool: Line 686: could not convert: raise 'appenddecl: Unknown variable definition key:', k RefactoringTool: Python 3 does not support string exceptions RefactoringTool: Line 1545: could not convert: raise 'postcrack: Expected block dictionary instead of ',block RefactoringTool: Python 3 does not support string exceptions RefactoringTool: ### In file ./numpy/lib/function_base.py ### RefactoringTool: Line 549: could not convert: raise 'Internal Shape Error' RefactoringTool: Python 3 does not support string exceptions RefactoringTool: There was 1 error: RefactoringTool: Can't parse ./numpy/linalg/lapack_lite/make_lite.py: ParseError: bad input: type=4, value='\n', context=('', (144, 29))
participants (5)
-
Bruce Southey
-
Charles R Harris
-
James Watson
-
Scott Sinclair
-
Stéfan van der Walt