|
3 | 3 | # vi: set ft=python sts=4 ts=4 sw=4 et:
|
4 | 4 | """The ants module provides basic functions for interfacing with ANTS tools."""
|
5 | 5 | import os
|
| 6 | +from packaging.version import Version, parse |
6 | 7 |
|
7 | 8 | # Local imports
|
8 |
| -from ... import logging, LooseVersion |
| 9 | +from ... import logging |
9 | 10 | from ..base import CommandLine, CommandLineInputSpec, traits, isdefined, PackageInfo
|
10 | 11 |
|
11 | 12 | iflogger = logging.getLogger("nipype.interface")
|
@@ -42,16 +43,17 @@ def parse_version(raw_info):
|
42 | 43 |
|
43 | 44 | # -githash may or may not be appended
|
44 | 45 | v_string = v_string.split("-")[0]
|
45 |
| - # if there is a 'v' at the beginning, it may be stripped |
46 |
| - v_string = v_string.lstrip('v') |
47 |
| - |
48 |
| - # 2.2.0-equivalent version string |
49 |
| - if "post" in v_string and LooseVersion(v_string) >= LooseVersion( |
50 |
| - "2.1.0.post789" |
51 |
| - ): |
52 |
| - return "2.2.0" |
53 |
| - else: |
54 |
| - return ".".join(v_string.split(".")[:3]) |
| 46 | + |
| 47 | + version = parse(v_string) |
| 48 | + |
| 49 | + # Known mislabeled versions |
| 50 | + if version.is_postrelease: |
| 51 | + if version.base_version == "2.1.0" and version.post >= 789: |
| 52 | + return "2.2.0" |
| 53 | + |
| 54 | + # Unless we know of a specific reason to re-version, we will |
| 55 | + # treat the base version (before pre/post/dev) as authoritative |
| 56 | + return version.base_version |
55 | 57 |
|
56 | 58 |
|
57 | 59 | class ANTSCommandInputSpec(CommandLineInputSpec):
|
|
0 commit comments