-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhance]: add version assert (#129)
* Add version assert in init file. * update mmcv requirement Co-authored-by: zhangwenwei <wayne.zw@outlook.com>
- Loading branch information
1 parent
96cab60
commit 3c166b2
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |