scottransom / presto

Open source pulsar search and analysis toolkit
http://www.cv.nrao.edu/~sransom/presto/
GNU General Public License v2.0
239 stars 177 forks source link

Installing `PRESTO`'s Python bindings fails for Python 3.12. #192

Closed astrogewgaw closed 7 months ago

astrogewgaw commented 8 months ago
Recently, I attempted to install `PRESTO`'s Python bindings into a [**Miniconda**](https://docs.anaconda.com/free/miniconda) environment, which had Python 3.12.1, and it failed with the following error: `ModuleNotFoundError: No module named 'numpy.distutils'`. A more detailed stack trace can be found below:
Click for detailed stack trace. ```bash Processing /home/upanda/soft/presto Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [20 lines of output] Traceback (most recent call last): File "/home/upanda/soft/conda/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/home/upanda/soft/conda/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/upanda/soft/conda/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-88h6i3t2/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-88h6i3t2/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires self.run_setup() File "/tmp/pip-build-env-88h6i3t2/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup super().run_setup(setup_script=setup_script) File "/tmp/pip-build-env-88h6i3t2/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup exec(code, locals()) File "", line 8, in ModuleNotFoundError: No module named 'numpy.distutils' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. ```
This has been an error I have been anticipating for a while, since [**PEP 632**](https://peps.python.org/pep-0632) suggested the removal of the `distutils` module from the Python standard library. This was accepted, with the final removal scheduled for Python 3.12. This was followed up the deprecation of the `numpy.distutils` in Numpy `1.23.0`, and as the relevant part of Numpy's documentation states [**here**](https://numpy.org/doc/stable/reference/distutils_status_migration.html), it has been removed for Python 3.12. Currently, I have circumvented the issue by installing the Python bindings for `PRESTO` into an older version of Python, Python 3.10. However, we might need to consider migrating `PRESTO` to a different build system, such as [**Meson**](https://mesonbuild.com) or [**CMake**](https://cmake.org), as suggested in Numpy's documentation [**here**](https://numpy.org/doc/stable/reference/distutils_status_migration.html#migration-advice).
scottransom commented 8 months ago

Yup, this was reported to me in another context recently. I am looking into changing the PRESTO build process to using Meson. Hopefully this will be done over the next couple months (at most!).

astrogewgaw commented 7 months ago

Glad to know you are already on this!

scottransom commented 7 months ago

Please see #194 Would be great if you were able to check out the new meason-based install!

astrogewgaw commented 7 months ago

Thanks @scottransom, this looks promising. I will try installations on a few (Linux) machines, and report back. Unfortunately I don't have a Mac or a Windows machine at hand, so I can't try those, but I will ask around.