Skip to content

Commit

Permalink
[Enhance]: add version assert (#129)
Browse files Browse the repository at this point in the history
* Add version assert in init file.

* update mmcv requirement

Co-authored-by: zhangwenwei <wayne.zw@outlook.com>
  • Loading branch information
yinchimaoliang and ZwwWayne authored Sep 24, 2020
1 parent 96cab60 commit 3c166b2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ pip install -v -e . # or "python setup.py develop"

| MMDetection3D version | MMDetection version | MMCV version |
|:-------------------:|:-------------------:|:-------------------:|
| master | mmdet>=2.4.0 | mmcv-full>=1.1.1, <=1.2|
| 0.6.0 | mmdet>=2.4.0 | mmcv-full>=1.1.1, <=1.2|
| master | mmdet>=2.4.0 | mmcv-full>=1.1.3, <=1.2|
| 0.6.0 | mmdet>=2.4.0 | mmcv-full>=1.1.3, <=1.2|
| 0.5.0 | 2.3.0 | mmcv-full==1.0.5|


Expand Down
35 changes: 35 additions & 0 deletions mmdet3d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
import mmcv

import mmdet
from .version import __version__, short_version


def digit_version(version_str):
digit_version = []
for x in version_str.split('.'):
if x.isdigit():
digit_version.append(int(x))
elif x.find('rc') != -1:
patch_version = x.split('rc')
digit_version.append(int(patch_version[0]) - 1)
digit_version.append(int(patch_version[1]))
return digit_version


mmcv_minimum_version = '1.1.3'
mmdet_maximum_version = '1.2'
mmcv_version = digit_version(mmcv.__version__)


assert (mmcv_version >= digit_version(mmcv_minimum_version)
and mmcv_version <= digit_version(mmdet_maximum_version)), \
f'MMCV=={mmcv.__version__} is used but incompatible. ' \
f'Please install mmcv>={mmcv_minimum_version}, <={mmdet_maximum_version}.'

mmdet_minimum_version = '2.4.0'
mmdet_maximum_version = '2.4.0'
mmdet_version = digit_version(mmdet.__version__)
assert (mmdet_version >= digit_version(mmdet_minimum_version)
and mmdet_version <= digit_version(mmdet_maximum_version)), \
f'MMDET=={mmdet.__version__} is used but incompatible. ' \
f'Please install mmdet>={mmdet_minimum_version}, ' \
f'<={mmdet_maximum_version}.'

__all__ = ['__version__', 'short_version']

0 comments on commit 3c166b2

Please # to comment.