qutip / qutip-cupy

CuPy linear-algebra backend for QuTiP
BSD 3-Clause "New" or "Revised" License
18 stars 10 forks source link

Remove direct cupy dependency from setup.cfg. #12

Closed hodgestar closed 3 years ago

hodgestar commented 3 years ago

Currently setup.cfg lists cupy as a dependency. This would make complete sense for an ordinary Python package, but cupy is really an umbrella package that is built for many different CUDA versions.

If cupy is not installed, conda handles this well and conda install cupy does the right thing.

However, pip install cupy without cupy already installed will always attempt to download the cupy source and built it, which is likely to fail with an obscure error message.

I think a friendlier user experience would be to remove cupy from setup.cfg and instead add something like:

try:
    import cupy
    del cupy
except ModuleNotFoundError:
    raise ImportError(
        "The qutip_cupy package depends on cupy, but cupy is not installed. Please"
        " read the installation instructions for cupy at https://docs.cupy.dev/en/stable/install.html"
        " and install the cupy package that matches your CUDA libraries."
    )

to qutip_cupy.__init__ so that the user gets a helpful error message when they attempt to import qutip_cupy rather than an obscure error message when they attempt to install it.

MrRobot2211 commented 3 years ago

solved in #17