odes icon indicating copy to clipboard operation
odes copied to clipboard

Add support for Python 3.12? (broken due to absence of `numpy.distutils`)

Open agriyakhetarpal opened this issue 7 months ago • 0 comments

Looks like numpy eventually and finally removed distutils with Python 3.12+, which breaks the installation of scikits.odes.

Steps to reproduce

  1. Install BLAS, C and Fortran compilers, etc.
  2. Set the SUNDIALS_INST environment variable
  3. pip install scikits.odes

Error trace

Using pip 23.3.1 from /Users/agriyakhetarpal/Desktop/venv/lib/python3.12/site-packages/pip (python 3.12)
Collecting scikits.odes
  Downloading scikits.odes-2.7.0.tar.gz (931 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 931.8/931.8 kB 1.2 MB/s eta 0:00:00
  Running command pip subprocess to install build dependencies
  Collecting setuptools<=64.0.0
    Using cached setuptools-64.0.0-py3-none-any.whl (1.2 MB)
  Collecting wheel
    Using cached wheel-0.41.3-py3-none-any.whl.metadata (2.2 kB)
  Collecting numpy
    Using cached numpy-1.26.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (61 kB)
  Collecting cython<3.0.0a8
    Using cached Cython-0.29.36-py2.py3-none-any.whl.metadata (3.1 kB)
  Using cached wheel-0.41.3-py3-none-any.whl (65 kB)
  Using cached numpy-1.26.2-cp312-cp312-macosx_11_0_arm64.whl (13.7 MB)
  Using cached Cython-0.29.36-py2.py3-none-any.whl (988 kB)
  Installing collected packages: wheel, setuptools, numpy, cython
  Successfully installed cython-0.29.36 numpy-1.26.2 setuptools-64.0.0 wheel-0.41.3
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  Traceback (most recent call last):
    File "/Users/agriyakhetarpal/Desktop/PyBaMM/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/Users/agriyakhetarpal/Desktop/PyBaMM/venv/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 "/Users/agriyakhetarpal/Desktop/PyBaMM/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
      backend = _build_backend()
                ^^^^^^^^^^^^^^^^
    File "/Users/agriyakhetarpal/Desktop/PyBaMM/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
      obj = import_module(mod_path)
            ^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/homebrew/Cellar/[email protected]/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 994, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "/private/var/folders/jg/wkd_9vqx7qlbdkrf0yw7hmtr0000gn/T/pip-build-env-_qr2l6p6/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
      import setuptools.version
    File "/private/var/folders/jg/wkd_9vqx7qlbdkrf0yw7hmtr0000gn/T/pip-build-env-_qr2l6p6/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
      import pkg_resources
    File "/private/var/folders/jg/wkd_9vqx7qlbdkrf0yw7hmtr0000gn/T/pip-build-env-_qr2l6p6/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2191, in <module>
      register_finder(pkgutil.ImpImporter, find_on_path)
                      ^^^^^^^^^^^^^^^^^^^
  AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
  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.
  full command: /Users/agriyakhetarpal/Desktop/PyBaMM/venv/bin/python3.12 /Users/agriyakhetarpal/Desktop/PyBaMM/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_wheel /var/folders/jg/wkd_9vqx7qlbdkrf0yw7hmtr0000gn/T/tmpx7all71r
  cwd: /private/var/folders/jg/wkd_9vqx7qlbdkrf0yw7hmtr0000gn/T/pip-install-7v61zx_l/scikits-odes_e3d217f0288b42d486580f9b89091baa
  Getting requirements to build wheel ... error
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.

Platform specifications

Operating system: macOS Sonoma Processor architecture: arm64 Python version: 3.12.0 Version of pip used to install: 23.0.1


Installing on Python 3.8–3.11 works fine, of course. Is there a plan to support Python 3.12 soon? I would have tried to do this in a PR but I am sure it would be very daunting to try an installation from source (probably the same though since PyPI has sdist and not pre-compiled binaries), plus the Extension and build_ext utilities from setuptools might not be able to handle the current packaging infrastructure present here: https://numpy.org/doc/stable/reference/distutils_status_migration.html#moving-to-setuptools.


xref: https://github.com/bmcage/odes/issues/130

agriyakhetarpal avatar Nov 16 '23 13:11 agriyakhetarpal