Skip opencv requirement if it's already installed in the env (i.e. via conda) (#616)

* Skip opencv requirement if it's already installed in the env

* pre-commit

* Check opencv conda version

* Check opencv conda version
This commit is contained in:
David de la Iglesia Castro 2020-10-17 11:58:25 +02:00 committed by GitHub
parent a260a96a0f
commit c8146cc52b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,12 +119,21 @@ def parse_requirements(fname='requirements.txt', with_version=True):
return packages
# If first not installed install second package
CHOOSE_INSTALL_REQUIRES = [('opencv-python-headless>=3', 'opencv-python>=3')]
install_requires = parse_requirements()
for main, secondary in CHOOSE_INSTALL_REQUIRES:
install_requires.append(choose_requirement(main, secondary))
try:
# OpenCV installed via conda.
import cv2 # NOQA: F401
major, minor, *rest = cv2.__version__.split('.')
if int(major) < 3:
raise RuntimeError(
f'OpenCV >=3 is required but {cv2.__version__} is installed')
except ImportError:
# If first not installed install second package
CHOOSE_INSTALL_REQUIRES = [('opencv-python-headless>=3',
'opencv-python>=3')]
for main, secondary in CHOOSE_INSTALL_REQUIRES:
install_requires.append(choose_requirement(main, secondary))
def get_extensions():