|
7 | 7 | import argparse |
8 | 8 | import os |
9 | 9 | import shutil |
10 | | -from distutils.version import StrictVersion |
| 10 | +from pkg_resources import parse_version |
11 | 11 |
|
12 | 12 | import switch_model |
13 | 13 |
|
|
35 | 35 | # Not every code revision requires an update; this is the last revision that did. |
36 | 36 | last_required_update = upgrade_plugins[-1][-1] |
37 | 37 |
|
38 | | -code_version = StrictVersion(switch_model.__version__) |
| 38 | +code_version = parse_version(switch_model.__version__) |
39 | 39 | version_file = 'switch_inputs_version.txt' |
40 | 40 | #verbose = False |
41 | 41 | verbose = True |
@@ -93,7 +93,7 @@ def do_inputs_need_upgrade(inputs_dir): |
93 | 93 | # Not every code revision requires an update, so just hard-code the last |
94 | 94 | # revision that required an update. |
95 | 95 | inputs_version = get_input_version(inputs_dir) |
96 | | - return StrictVersion(inputs_version) < StrictVersion(last_required_update) |
| 96 | + return parse_version(inputs_version) < parse_version(last_required_update) |
97 | 97 |
|
98 | 98 |
|
99 | 99 | def _backup(inputs_dir): |
@@ -122,15 +122,15 @@ def upgrade_inputs(inputs_dir, backup=True, assign_current_version=False): |
122 | 122 | _backup(inputs_dir) |
123 | 123 | # Successively apply the upgrade scripts as needed. |
124 | 124 | for (upgrader, v_from, v_to) in upgrade_plugins: |
125 | | - inputs_v = StrictVersion(get_input_version(inputs_dir)) |
| 125 | + inputs_v = parse_version(get_input_version(inputs_dir)) |
126 | 126 | # note: the next line catches datasets created by/for versions of Switch that |
127 | 127 | # didn't require input directory upgrades |
128 | | - if StrictVersion(v_from) <= inputs_v < StrictVersion(v_to): |
| 128 | + if parse_version(v_from) <= inputs_v < parse_version(v_to): |
129 | 129 | print_verbose('\tUpgrading from ' + v_from + ' to ' + v_to) |
130 | 130 | upgrader.upgrade_input_dir(inputs_dir) |
131 | 131 | upgraded = True |
132 | 132 |
|
133 | | - if (StrictVersion(last_required_update) < StrictVersion(switch_model.__version__) |
| 133 | + if (parse_version(last_required_update) < parse_version(switch_model.__version__) |
134 | 134 | and assign_current_version): |
135 | 135 | # user requested writing of current version number, even if no upgrade is needed |
136 | 136 | # (useful for updating examples to track with new release of Switch) |
|
0 commit comments