1

I am trying write the setup script for my Python package which uses faiss such that an end user can install the CPU version of my package by default or specify a GPU-enabled version using extras_require. The problem is that faiss breaks if both faiss-cpu and faiss-gpu are simultaneously installed in the environment.

My setup script looks something like this:

setup(
    ...
    install_requires=[
        "faiss-cpu==1.7.0",
        ...,
    ],
    extras_require=(
        "gpu": ["faiss-gpu==1.7.0", ...],
        ...,
    ),
)

Things work as expected when my package is installed with no extras, but if [gpu] is specified then both faiss-cpu and faiss-gpu are installed. The only way to resolve this is to manually uninstall both faiss-cpu and faiss-gpu, then reinstall faiss-gpu (interestingly, simply uninstalling faiss-cpu does not work).

How can I write or redesign my setup script to avoid this issue?

phd
  • 82,685
  • 13
  • 120
  • 165
void_panda
  • 53
  • 5
  • 1
    There is no any simple way. The only way is to put both in `extras_require` and document that a user must install either `package[cpu]` or `package[gpu]` but not both. – phd Dec 29 '22 at 16:59

0 Answers0