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?