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

numpy.f2py.compile removed since NumPy 2.0.0 causing test failures #103

Open
kanamesasaki opened this issue Dec 18, 2024 · 0 comments
Open

Comments

@kanamesasaki
Copy link

kanamesasaki commented Dec 18, 2024

Describe the bug
numpy.f2py.compile function has been removed since NumPy 2.0.0 (https://numpy.org/doc/stable/release/2.0.0-notes.html), causing the python/Fortran test code in psychrolib to fail. The following error message is displayed when executing "pytest -v -s"

ImportError while loading conftest '/workspaces/psychrolib/tests/conftest.py'.
tests/conftest.py:26: in <module>
    f2py.compile(source , modulename='psychrolib_fortran', extension='.f90')
/usr/local/lib/python3.11/site-packages/numpy/f2py/__init__.py:82: in __getattr__
    raise AttributeError("module {!r} has no attribute "
E   AttributeError: module 'numpy.f2py' has no attribute 'compile'

To Reproduce
Steps to reproduce the behavior:

  1. see Environment for the installed packages
  2. execute: python -m pytest -v -s

Environment:

  • Docker container based on python:3.11-slim
  • Installed python packages:
    cffi 1.17.1
    charset-normalizer 3.4.0
    iniconfig 2.0.0
    numpy 2.2.0
    packaging 24.2
    pip 24.0
    pluggy 1.5.0
    PsychroLib 2.5.0 /psychrolib/src/python
    pycparser 2.22
    pytest 8.3.4
    setuptools 65.5.1
    wheel 0.45.1

Additional comment
A possible workaround is to use subprocess.run to directly call f2py
Example:

import subprocess

PATH_TO_LIB = Path(__file__).parents[1] / 'src' / 'fortran' / 'psychrolib.f90'
subprocess.run(['f2py', '-c', '-m', 'psychrolib_fortran', str(PATH_TO_LIB)], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant