Skip to content

Commit

Permalink
fix version
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferydeng committed Mar 18, 2024
1 parent 77bbb05 commit a520b7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist_blade
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function make_blade_zip() {

cd $src_dir

echo "VERSION = r'''$version'''" > blade/version.py
echo "BLADE_VERSION = r'''$version'''" > blade/blade_version.py
zip blade.zip __main__.py blade/*.py
rm blade/version.py
rm blade/blade_version.py
mv ./blade.zip ${dist_file_path}

cd $blade_dir
Expand Down
6 changes: 3 additions & 3 deletions src/blade/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

# The 'version.py' is generated by the dist script, then it only exists in blade.zip
try:
from blade.version import VERSION
from blade.blade_version import BLADE_VERSION
except ImportError:
VERSION = '(developing, unversioned)'
BLADE_VERSION = '(developing, unversioned)'


class CommandLineParser(object):
Expand Down Expand Up @@ -418,7 +418,7 @@ def _build_arg_parser(self):
"""Add command options, add options whthin this method."""
blade_cmd_help = 'blade <subcommand> [options...] [targets...]'
arg_parser = argparse.ArgumentParser(prog='blade', description=blade_cmd_help)
arg_parser.add_argument('--version', action='version', version='%(prog)s ' + VERSION)
arg_parser.add_argument('--version', action='version', version='%(prog)s ' + BLADE_VERSION)
sub_parser = arg_parser.add_subparsers(dest='command', help='Available subcommands')

sub_parser.required = True
Expand Down
11 changes: 9 additions & 2 deletions src/blade/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
"""

import re
import sys
import warnings
import contextlib

_IN_PY2 = sys.version_info[0] == 2


@contextlib.contextmanager
def suppress_known_deprecation():
Expand Down Expand Up @@ -149,8 +152,12 @@ class StrictVersion(Version):
in the distutils documentation.
"""

if _IN_PY2:
char_flags = re.UNICODE
else:
char_flags = re.ASCII
version_re = re.compile(
r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$', re.VERBOSE | re.ASCII
r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$', re.VERBOSE | char_flags
)

def parse(self, vstring):
Expand Down Expand Up @@ -356,4 +363,4 @@ def _cmp(self, other):
return 1


# end class LooseVersion
# end class LooseVersion

0 comments on commit a520b7d

Please sign in to comment.