presto icon indicating copy to clipboard operation
presto copied to clipboard

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

Open astrogewgaw opened this issue 11 months ago • 4 comments

Recently, I attempted to install PRESTO's Python bindings into a 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.
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 <module>
          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 "<string>", line 8, in <module>
      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 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, 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 or CMake, as suggested in Numpy's documentation here.

astrogewgaw avatar Mar 19 '24 05:03 astrogewgaw

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!).

scottransom avatar Mar 19 '24 14:03 scottransom

Glad to know you are already on this!

astrogewgaw avatar Mar 25 '24 11:03 astrogewgaw

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

scottransom avatar Apr 04 '24 21:04 scottransom

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.

astrogewgaw avatar Apr 06 '24 07:04 astrogewgaw