mirror of
https://github.com/open-mmlab/mmcv.git
synced 2025-06-03 21:54:52 +08:00
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:
parent
a260a96a0f
commit
c8146cc52b
19
setup.py
19
setup.py
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user