evaleev / libint

Libint: high-performance library for computing Gaussian integrals in quantum mechanics
Other
218 stars 96 forks source link

python 3.12 #274

Open loriab opened 8 months ago

loriab commented 8 months ago

Just a PSA that pylibint isn't working nicely with python 3.12. I see it locally on Linux, and GHA hits it on Mac.

There's some setup.py test complaints, but even running unittest directly, the third test segfaults. I haven't had problems with py312 and other pybind11 projects, so I'm not sure what's the trouble.

Anyways, this doesn't hinder me, but I'm posting in case others hit it. (If it's needed for CI before #271 is merged, change python3 -> python@3.11 for homebrew.)

e-kwsm commented 8 months ago

setuptools v41.5.0 deprecated the test command https://setuptools.pypa.io/en/latest/history.html#v41-5-0.

e-kwsm commented 8 months ago

I tried to build libint exported from ca32e0c32071accb6074cdd023b4721d06a454f7, with python 3.11 and pybind11 v2.6.0 as downloaded by libint, but failed:

In file included from exported/build/_deps/pybind11-src/include/pybind11/attr.h:13,
                 from exported/build/_deps/pybind11-src/include/pybind11/pybind11.h:45,
                 from exported/python/src/libint2/libint2.cc:13:
build/_deps/pybind11-src/include/pybind11/cast.h: In function ‘std::string pybind11::detail::error_string()’:
build/_deps/pybind11-src/include/pybind11/cast.h:446:36: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                    ^~

See https://docs.python.org/3.11/whatsnew/3.11.html#pyframeobject-3-11-hiding and pybind/pybind11#4464. pybind11 v2.10.0 or later is required.

e-kwsm commented 8 months ago

With pybind11 v2.10.0, python3 setup.py test fails but it seems unrelated with libint.

loriab commented 8 months ago

Thanks for investigating. fwiw, I was using pybind11 v2.11.1 .

loriab commented 7 months ago

So CI is failing again (see #262, #275, #276) on Mac once these were rebased to include the homebrew python@3.11 workaround to py312 failure.

My theory is that the GHA macOS image has, for a long time, had an old Python. https://github.com/actions/runner-images#available-images shows macos-latest bringing py27 (not a typo: 2.7). In this case, the homebrew upgrades python. And because homebrew "features" a weird-to-me takeover of system Python, pylibint2 finds the new py311, and all's well.

In my experience, even requesting macos-latest sometimes brings a variety of images (system python not always ==py27) as GHA rolls out runner images. So what the L2 CI is now seeing is the new macos-13 that comes with py312. Then homebrew declines to downgrade python to 311, and pylibint2 picks up py312 and fails.

Idk which of the three following strategies should be pursued:

evaleev commented 7 months ago

There's some setup.py test complaints, but even running unittest directly, the third test segfaults. I haven't had problems with py312 and other pybind11 projects, so I'm not sure what's the trouble.

I think support for 3.12 may not be complete even in pybind11 master. In Libint2's python "unit" test I seemed to have run into this problem when trying 3.12 with master pybind11:

image