geophysics / mtpy

collection of python tools for standard MT data processing
GNU General Public License v3.0
32 stars 32 forks source link

Python 2.4 Compatibility #24

Open kujaku11 opened 10 years ago

kujaku11 commented 10 years ago

I've had a bug report from a potential user that MTpy is not compatible with Python 2.4 or 2.5. It doesn't seem like a huge deal to make it 2.4 compatible (see error list below, mostly change with statement and logic syntax in lists) just some syntax changes. The questions is should we fork a branch that is compatible with 2.4 which will be compatible with 2.x or always use 2.4 syntax, which defeats some the great things about current Python versions. Any thoughts? I made a branch called Python_v_2.4 as a start to see how much work it would be. I'm also not positive about how compatible some of the major packages (Numpy, Scipy, Matplotlib, etc) we use are backwards compatible to 2.4.

running install running build running build_py running build_scripts running install_lib byte-compiling /usr/lib/python2.4/site-packages/mtpy/utils/misc.py to misc.pyc File "/usr/lib/python2.4/site-packages/mtpy/utils/misc.py", line 145 class MemoryCheck(): ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/utils/configfile.py to configfile.pyc File "/usr/lib/python2.4/site-packages/mtpy/utils/configfile.py", line 119 with open(filename) as F: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/utils/remove_instrumentresponse_from_files.py to remove_instrumentresponse_from_files.pyc File "/usr/lib/python2.4/site-packages/mtpy/utils/remove_instrumentresponse_from_files.py", line 81 lo_channels = list(set([i.upper() if len(i)==2 else 'B'+i.upper() for i in sys.argv[4].split(',')])) ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/utils/convert_coordinates_in_edis.py to convert_coordinates_in_edis.pyc File "/usr/lib/python2.4/site-packages/mtpy/utils/convert_coordinates_in_edis.py", line 78 with open(infile,'r') as F: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/utils/filehandling.py to filehandling.pyc File "/usr/lib/python2.4/site-packages/mtpy/utils/filehandling.py", line 578 with open(tsfile,'r') as F: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/test/utils.py to utils.pyc File "/usr/lib/python2.4/site-packages/mtpy/test/utils.py", line 40 with open(i,'r') as f: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/test/basic.py to basic.pyc File "/usr/lib/python2.4/site-packages/mtpy/test/basic.py", line 23 with self.assertRaises(ValueError): ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/analysis/distortion.py to distortion.pyc File "/usr/lib/python2.4/site-packages/mtpy/analysis/distortion.py", line 345 lo_dims = [ 4 if i == 1 else i for i in lo_dims ] ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/analysis/pt.py to pt.pyc File "/usr/lib/python2.4/site-packages/mtpy/analysis/pt.py", line 922 class ResidualPhaseTensor(): ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/processing/birrp.py to birrp.pyc File "/usr/lib/python2.4/site-packages/mtpy/processing/birrp.py", line 239 with open(string_file,'w') as F: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/processing/io.py to io.pyc File "/usr/lib/python2.4/site-packages/mtpy/processing/io.py", line 58 with open(filename, 'r') as f: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/modeling/occam1d.py to occam1d.pyc File "/usr/lib/python2.4/site-packages/mtpy/modeling/occam1d.py", line 1803 class PlotL2(): ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/modeling/occam2d.py to occam2d.pyc File "/usr/lib/python2.4/site-packages/mtpy/modeling/occam2d.py", line 73 class Setup(): ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/core/edi.py to edi.pyc File "/usr/lib/python2.4/site-packages/mtpy/core/edi.py", line 176 with open(infile,'r') as F: ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/usgs/zonge.py to zonge.pyc File "/usr/lib/python2.4/site-packages/mtpy/usgs/zonge.py", line 34 class ZongeMTFT(): ^ SyntaxError: invalid syntax byte-compiling /usr/lib/python2.4/site-packages/mtpy/usgs/zen.py to zen.pyc File "/usr/lib/python2.4/site-packages/mtpy/usgs/zen.py", line 2137 class ZenBIRRP(): ^ SyntaxError: invalid syntax running install_scripts changing mode of /usr/bin/ws2vtk.py to 755

kinverarity1 commented 10 years ago

For background information: in the past 18 months, numpy, scipy, and matplotlib have all dropped support for Python < 2.6. Numpy did it as of Oct 2013 with 1.8; scipy did it in April 2013 with 0.12; and matplotlib in Nov 2012 with 1.2. So far as I understand they did so in order to support Python 3+, which I imagine mtpy is unable to run on. I would suggest making the changes to support Python 2.4 & 2.5 in the master branch, and instead maintaining/working on Python 3+ compatibility (i.e. minimum python 2.6 requirement) in a branch. That's how every pretty much every other project I've seen is managing the transition.

kinverarity1 commented 10 years ago

Changes to look out for are here: http://docs.python.org/2/whatsnew/2.5.html http://docs.python.org/2/whatsnew/2.6.html

Also I've been looking through some of those errors:

  1. sets are inbuilt types in >2.6, but live in the sets standard library module in <2.6
  2. with statements were unfortunately only introduced in 2.5
  3. inline if statements (5 if x == 2 else 10) were only introduced in 2.5

I'm not sure what the class errors are about.

kujaku11 commented 10 years ago

Thanks for that Kent. So who wants to make the changes? For the most part they look relatively easy. I also don't know about the class errors.

hugovk commented 7 years ago

[3.5 years later...]

Is Python 2.4 still needed? Many packages are now dropping 2.6.