mirror of
https://github.com/open-mmlab/mmengine.git
synced 2025-06-03 21:54:44 +08:00
[Fix] add required lib for vis (#111)
* add required lib for vis * fix comment
This commit is contained in:
parent
98097bb73e
commit
3bdd27c4e2
@ -1,4 +1,5 @@
|
||||
addict
|
||||
matplotlib
|
||||
numpy
|
||||
pyyaml
|
||||
regex;sys_platform=='win32'
|
||||
|
32
setup.py
32
setup.py
@ -1,5 +1,8 @@
|
||||
import re
|
||||
from setuptools import find_packages, setup # type: ignore
|
||||
|
||||
from pkg_resources import DistributionNotFound, get_distribution
|
||||
|
||||
|
||||
def readme():
|
||||
with open('README.md', encoding='utf-8') as f:
|
||||
@ -10,6 +13,18 @@ def readme():
|
||||
version_file = 'mmengine/version.py'
|
||||
|
||||
|
||||
def choose_requirement(primary, secondary):
|
||||
"""If some version of primary requirement installed, return primary, else
|
||||
return secondary."""
|
||||
try:
|
||||
name = re.split(r'[!<>=]', primary)[0]
|
||||
get_distribution(name)
|
||||
except DistributionNotFound:
|
||||
return secondary
|
||||
|
||||
return str(primary)
|
||||
|
||||
|
||||
def get_version():
|
||||
with open(version_file, 'r') as f:
|
||||
exec(compile(f.read(), version_file, 'exec'))
|
||||
@ -92,6 +107,21 @@ def parse_requirements(fname='requirements/runtime.txt', with_version=True):
|
||||
return packages
|
||||
|
||||
|
||||
install_requires = parse_requirements()
|
||||
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))
|
||||
|
||||
setup(
|
||||
name='mmengine',
|
||||
version=get_version(),
|
||||
@ -104,7 +134,7 @@ setup(
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
python_requires='>=3.6',
|
||||
install_requires=parse_requirements('requirements/runtime.txt'),
|
||||
install_requires=install_requires,
|
||||
extras_require={
|
||||
'all': parse_requirements('requirements.txt'),
|
||||
'tests': parse_requirements('requirements/tests.txt'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user