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

Python 3.12 f2py compile error #244

Closed
the-hampel opened this issue Oct 19, 2023 · 1 comment
Closed

Python 3.12 f2py compile error #244

the-hampel opened this issue Oct 19, 2023 · 1 comment
Assignees
Labels

Comments

@the-hampel
Copy link
Member

As of Python version 3.12 distutils has been removed. This causes some compiler error when building the elk converter via f2py:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/.venv/py312/lib/python3.12/site-packages/numpy/f2py/__main__.py", line 5, in <module>
    main()
  File "/.venv/py312/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 732, in main
    run_compile()
  File "/.venv/py312/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 705, in run_compile
    builder.compile()
  File "/.venv/py312/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 131, in compile
    self.run_meson(self.build_dir)
  File "/.venv/py312/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 117, in run_meson
    raise subprocess.CalledProcessError(
subprocess.CalledProcessError: Command '['meson', 'setup', 'bbdir']' returned non-zero exit status 1.

which is the following error in the meson log:

Could not introspect Python (['/.venv/py312/bin/python3.12', '/.venv/py312/lib/python3.12/site-packages/mesonbuild/scripts/python_info.py']): exit code 1
Program stdout:


Program stderr:

Traceback (most recent call last):
  File "/.venv/py312/lib/python3.12/site-packages/mesonbuild/scripts/python_info.py", line 16, in <module>
    import distutils.command.install
ModuleNotFoundError: No module named 'distutils'


meson.build:10:22: ERROR: <PythonExternalProgram 'python3' -> ['/.venv/py312/bin/python3.12']> is not a valid python or it is missing distutils
(END)

I have no idea why meson is trying to run this file, or it is corrupted. In principle, the issue is documented here: https://numpy.org/doc/stable/f2py/buildtools/index.html and discussed here: numpy/numpy#24838 .

However, changing:

COMMAND ${TRIQS_PYTHON_EXECUTABLE} -m numpy.f2py --f90exec=${CMAKE_Fortran_COMPILER} --f77exec=${CMAKE_Fortran_COMPILER} -c ${fortran_src_file} -m ${module_name} > elk_f2py.log

to (as suggested):

COMMAND ${TRIQS_PYTHON_EXECUTABLE} -m numpy.f2py -c ${fortran_src_file} -m ${module_name} --lower > elk_f2py.log

does not fix it.

Working on it... Any ideas welcome.

@the-hampel the-hampel added the bug label Oct 19, 2023
@the-hampel the-hampel self-assigned this Oct 19, 2023
@the-hampel
Copy link
Member Author

Installing setuptools fixes the problem: mesonbuild/meson#7702 . Then meson does the right thing. No adaptations in our cmake files required apparently. A working ubuntu 22.04 dockerfile can be found here:
https://github.com/the-hampel/Dockerfiles/blob/master/triqs3-dev/triqs-32x-py312-dockerfile .

Thanks to @Thoemi09 for helping.

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

No branches or pull requests

1 participant