Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fortranmagic should call f2py3 under Python 3 #9

Closed
vallis opened this issue Feb 12, 2015 · 7 comments
Closed

fortranmagic should call f2py3 under Python 3 #9

vallis opened this issue Feb 12, 2015 · 7 comments

Comments

@vallis
Copy link

vallis commented Feb 12, 2015

Otherwise it will silently use an f2py that may have a hardcoded #!/usr/bin/python27 at the top, resulting in puzzling errors because the compiled objects look at the wrong Python includes.

@mgaitan
Copy link
Owner

mgaitan commented Feb 12, 2015

Hey @vallism, you are right, thanks for the report.

This bug was introduced after #8 . Before that, instead to run the command f2py via a subprocess call, we directly called the f2py.main() function.

I'm not sure if the better idea is to undo that change and handle the Window's problem it fixes with a different approach, or make the call to the proper f2py script depending the python version.

For the latter, I'm not sure if append the python version would be enough. For example, in my computer (w/ubuntu) I have these:

tin@morochita:~/lab/fortran_magic$ f2py<tab>
f2py     f2py2.7  f2py3.4  

but is this common to any system/os?

@vallis
Copy link
Author

vallis commented Feb 12, 2015

This may be a question for the numpy.f2py developers. I looked in their github, and there's no mention of f2py3, so I suspect that it may be something that packagers add.

On my anaconda Python 2.7 + 3.4 installation on OS X, I have f2py under the main /bin directory, and f2py3 under the python 3 sub-environment. On my homebrew Python 2.7 + 3.4 installation, I have only f2py2.7 in /usr/local/bin; the pip-installed numpy creates f2py for both Python 2.7 and 3, but with the wrong hash-bang... Basically, it's all over the place.

Perhaps you could do the awkward thing, and call f2py.main on anything else than windows. Another solution, less transparent to the user but still OK IMHO, would be to allow selecting the f2py executable in the iPython magic.

@mgaitan
Copy link
Owner

mgaitan commented Feb 12, 2015

Maybe the great numpy's maintainers @charris or @juliantaylor can help us: Is there a multiplatform python2/3 compatible way to run f2py programatically (i.e from Python) ?

@juliantaylor
Copy link

should just be numpy.f2py.compile

the f2py binary is just a wrapper around numpy.f2py functions so you should be able to do everything from python

@juliantaylor
Copy link

no idea why it originally doesn't work for windows directly from python. that would be interesting to figure out but i have no windows.
otherwise maybe one can use the python -m thing (pep338), with python being sys.executable, though I have no idea if that invocation method works with f2py, but that should be fixable if not

@juliantaylor
Copy link

too bad doesn't work, but added numpy/numpy#5565

@astrojuanlu
Copy link
Contributor

I just checked and replacing the f2py call with python -m numpy.f2py works, but it requires NumPy 1.10 (see numpy/numpy@29c019a). Since it seems to be the simplest solution, @mgaitan would you accept a pull request with this change and tag a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants