pasqal-io / Pulser

Library for pulse-level/analog control of neutral atom devices. Emulator with QuTiP.
Apache License 2.0
181 stars 65 forks source link

Pulser doesn't install on Python 3.13 #757

Open awennersteen opened 1 month ago

awennersteen commented 1 month ago

Trying to install Pulser on Python 3.13 fails due to issues with building QuTiP and also the supported SciPy version of QuTiP.

Here is a way to replicate via Docker containers, the same process works with Python 3.12 container (you don't need to install anything via apt with python 3.12 as everything comes pre-built)

The issue appears to come from restricting SciPy < 1.13 in pulser-simulation: https://github.com/pasqal-io/Pulser/pull/668 I checked and the error in that issue error still persists in SciPy 1.14.1, and is marked as unsupported also in QuTiP now from 4.7.6.

The QuTiP issue of course is that we haven't upgraded to version 5, as detailed in #730 .

docker pull python:3.13
docker run -it python bash
root@bc1448bacafb:/# apt update && apt install -y build-essential gfortran libopenblas-dev
root@bc1448bacafb:/# pip install pulser

Also trying to build qutip, bypassing scipy restriction, seems to fail independently:

      qutip/control/cy_grape.cpp: In function ‘int __Pyx_PyInt_As_int(PyObject*)’:
      qutip/control/cy_grape.cpp:7770:46: error: too few arguments to function ‘int _PyLong_AsByteArray(PyLongObject*, unsigned char*, size_t, int, int, int)’
       7770 |                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
            |                           ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
       7771 |                                               bytes, sizeof(val),
            |                                               ~~~~~~~~~~~~~~~~~~~
       7772 |                                               is_little, !is_unsigned);
            |                                               ~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from /usr/local/include/python3.13/longobject.h:107,
                       from /usr/local/include/python3.13/Python.h:81,
                       from qutip/control/cy_grape.cpp:34:
      /usr/local/include/python3.13/cpython/longobject.h:111:17: note: declared here
        111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
            |                 ^~~~~~~~~~~~~~~~~~~

This appears to be a Python C-API issue. Seeing that they don't support version 4.x of QuTiP anymore I feel we will have to either upgrade to QuTiP 5, drop qutip as a backend, or restrict to at most Python 3.12 - which isn't a long-term solution (although not super urgent)