Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible requirements (allow for opencv-python or opencv-python-headless) #371

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Erotemic
Copy link

I was looking through the code and noticed that the setup.py was using a the parse_requirements function that I wrote some time back. I also noticed there was an explicit dependency on opencv-python. This causes issues for reasons that I outline in an mmdet PR: open-mmlab/mmcv#2775

I've made a few changes / upgrades:

  • moved requirements.txt -> requirements/runtime.txt
  • Added requirements/cv2.txt. and requirements/cv2-headless.txt
  • Added a new requirements.txt that references requirements/runtime.txt and requirements/cv2.txt (this means that pip install -r requirements.txt works exactly as before).
  • Changed setup.py to depend only on requirements/runtime.txt, this means that to get a full install, the user will have to specify pip install -e .[cv2] xor pip install -e .[cv2-headless], which unfortunately is unavoidable if you want to support the ability to use either version of the cv2 package. This is a minor breaking change.
  • Added minimum versions to all requirements
  • Added the ability to pip install -e .[runtime-strict,cv2-strict], which will install the package with dependencies pinned to the minimum version (very useful for testing / ensuring upstream package changes don't break your code).

In summary this adds:

  • Feature: Gives the user flexibility to use either opencv-python or opencv-python-headless
  • Feature: Gives the user the ability to install requirements with "strict" versions, where dependencies are pinned to minimum versions
  • Minor Breaking Change: Means that you can no longer pip install -e . to install all dependencies you have to pip install -e .[cv2] xor pip install -e .[cv2-headless] or preinstall the opencv package you want.

Pending review additional work that may need to be done:

  • Update any install scripts to choose which version of cv2 to use.
  • Check if the chosen minimum versions are reasonable or if they need to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant