0

This is a followup to this question

Installing a pip package with cupy as a requirement puts install in never ending loop

Where somehow a pip package was not able to detect that cupy is already installed, and tried to re-install it.

The solution given was to use

try:
  import cupy
except Exception:
  install_requires.append('cupy')

Which worked for when I tried to install through github with

!pip install https://github.com/Santosh-Gupta/SpeedTorch/archive/master.zip

However, when I uploaded by code to pip and tried to run it, it's re-installing cupy again

!pip install SpeedTorch

I am using Goolgle colab, which already has cupy installed. For convenience, here's a link to the notebook I am using

https://colab.research.google.com/drive/17KrdcHh29cpFMel_oYnOTkA1dNElolZ1

And here is my setup.py file

https://github.com/Santosh-Gupta/SpeedTorch/blob/master/setup.py

This problem may be unique to cupy, since I do not have this issue with other python packages.

SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116

1 Answers1

2

This is not issue specific to CuPy. You should not modify install_requires in setup.py if you want to distribute your package as a wheel. setup.py runs when building a wheel package, not when installing it. In other words, install_requires is determined depending on whether cupy is available when building a wheel package.

kmaehashi
  • 879
  • 6
  • 10