Skip to content

Commit b5b1a28

Browse files
Updating version parser because the prior one (distutils.version) is obsolete, violates current python version guides (PEP 440), and undocumented. The new parser is part of setuptools, which is required to install switch (it's an import in setup.py).
Changing version number from alpha to dev which seems a better name for this staging branch.
1 parent 766e377 commit b5b1a28

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

switch_model/upgrade/manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import argparse
88
import os
99
import shutil
10-
from distutils.version import StrictVersion
10+
from pkg_resources import parse_version
1111

1212
import switch_model
1313

@@ -35,7 +35,7 @@
3535
# Not every code revision requires an update; this is the last revision that did.
3636
last_required_update = upgrade_plugins[-1][-1]
3737

38-
code_version = StrictVersion(switch_model.__version__)
38+
code_version = parse_version(switch_model.__version__)
3939
version_file = 'switch_inputs_version.txt'
4040
#verbose = False
4141
verbose = True
@@ -93,7 +93,7 @@ def do_inputs_need_upgrade(inputs_dir):
9393
# Not every code revision requires an update, so just hard-code the last
9494
# revision that required an update.
9595
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)
9797

9898

9999
def _backup(inputs_dir):
@@ -122,15 +122,15 @@ def upgrade_inputs(inputs_dir, backup=True, assign_current_version=False):
122122
_backup(inputs_dir)
123123
# Successively apply the upgrade scripts as needed.
124124
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))
126126
# note: the next line catches datasets created by/for versions of Switch that
127127
# 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):
129129
print_verbose('\tUpgrading from ' + v_from + ' to ' + v_to)
130130
upgrader.upgrade_input_dir(inputs_dir)
131131
upgraded = True
132132

133-
if (StrictVersion(last_required_update) < StrictVersion(switch_model.__version__)
133+
if (parse_version(last_required_update) < parse_version(switch_model.__version__)
134134
and assign_current_version):
135135
# user requested writing of current version number, even if no upgrade is needed
136136
# (useful for updating examples to track with new release of Switch)

switch_model/version.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
22
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
33
"""
4-
This file should only include the version. Do not import any packages or
5-
modules here because this file needs to be executed before Switch is
6-
installed and executed in environments that don't have any dependencies
7-
installed.
4+
This file should not contain anything that is not part of a minimal python
5+
distribution because it needs to be executed before Switch (and its
6+
dependencies) are installed.
87
"""
9-
__version__='2.0.6-alpha'
8+
__version__='2.0.6-dev'

0 commit comments

Comments
 (0)