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