pyclaw
pyclaw copied to clipboard
pyclaw must be built with proper version of f2py for Python3
I ran into problems getting pyclaw to run recently in a conda environment that also had some other things I needed, and where Python3 is being used. @mandli and I finally tracked the problem down to the fact that 'pip install -e .' had been performed in my clawpack directory using the Python2 version of f2py. After doing pip install --upgrade numpy in the conda environment and then 'pip install -e .' in the clawpack directory from within that environment, I could import pyclaw Riemann solvers in Python3 (but no longer in Python2). So I need two different pyclaw directories if I want to switch Python versions.
This is something that should be explained somewhere in the installation docs somewhere perhaps?
(maybe you already know all of the following, but here it is for posterity)
This is technically not a Python 2/3 issue, but an issue with specific versions of numpy. Annoyingly, the numpy devs decided to change the extension of the shared-object files created by f2py in a recent release, breaking both forward and backward compatibility.
Also, this is not much different from the general issue that if you install a package for python 2 you won't have it for Python 3 and vice versa. If you do
pip2 install clawpack
and then
pip3 install clawpack
it will work fine in both Python 2 and 3. The issue you ran into is specific to using an in-place installation, and would be the same for other Python packages that use f2py.
We're 18 months from the death of Python 2 in scientific computing (see https://docs.scipy.org/doc/numpy/neps/dropping-python2.7-proposal.html) so I think it would be best to just advise people to move to Python 3.
One more thing: I would think it is possible to use the same clawpack directory for both installs; the shared-object files with the different extensions should happily co-exist. Did you delete your .so files created by the older version of f2py? Or am I missing something?
Thanks @ketch for the explanation. This makes sense and indeed I did delete the old .so files at some point in the process of trying to build new ones.
It might be optimal if everyone just moved to Python 3, but I think it is quite possible that some potential pyclaw users also use other packages in their work that have not yet been converted to Python 3, and so must maintain Python 2 environments too. Since we've worked hard to make our code work in either 2 or 3, it seems worthwhile to provide a bit more documentation on how to do so.
That's true. I will add something when I am back in a place with real internet access.
Providing a timeline or roadmap for the transition, including deprecation warnings for Python 2 support would work. Also Compatibility matrix in the documentation, listing which versions of pyclaw are compatible with which versions of Python and its dependencies.
@RuchitTripathi as you can see this issue is from 5 years ago. Now (in 2023) the entire scientific Python community has dropped support for Python 2. I'll close this issue since it's not relevant anymore.