From 1774e88b30498680ce087c71f5268ce0b126d44e Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 21 Jun 2018 16:37:58 -0700 Subject: [PATCH] better version handling --- tools/odrive/version.py | 4 +++- tools/setup.py | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/odrive/version.py b/tools/odrive/version.py index 5158a612..9c98f0be 100644 --- a/tools/odrive/version.py +++ b/tools/odrive/version.py @@ -36,7 +36,7 @@ def get_version_from_git(): print(ex) return "[unknown version]", 0, 0, 0, 1 -def get_version_str(git_only=False, is_post_release=False): +def get_version_str(git_only=False, is_post_release=False, bump_rev=False): """ Returns the versions of the tools If git_only is true, the version.txt file is ignored even @@ -52,6 +52,8 @@ def get_version_str(git_only=False, is_post_release=False): return version_file.readline().rstrip('\n') _, major, minor, revision, unreleased = get_version_from_git() + if bump_rev: + revision += 1 version = '{}.{}.{}'.format(major, minor, revision) if is_post_release: version += ".post" diff --git a/tools/setup.py b/tools/setup.py index 7f5bd61a..d5e38eff 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -22,7 +22,8 @@ To make a real release ensure you're at the release commit and then run the above command without the "test" (so just "pypi"). To install a prerelease version from test index: - sudo pip install --pre --index-url https://test.pypi.org/simple/ --no-cache-dir odrive +(extra-index-url is there because some packages don't upload to test server) + sudo pip install --pre --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --no-cache-dir odrive PyPi access requires that you have set up ~/.pypirc with your @@ -30,11 +31,13 @@ PyPi credentials and that your account has the rights to publish packages with the name odrive. """ -# Change this if you already uploaded the current -# version but need to release a hotfix -hotfix = 0 # Set to true to make an official post-release, rather than dev of new version is_post_release = False +post_rel_num = 5 + +# To test higher numbered releases, bump to the next rev +bump_rev = not is_post_release +devnum = 1 # TODO: add additional y/n prompt to prevent from erroneous upload @@ -46,15 +49,17 @@ creating_package = "sdist" in sys.argv # Load version from Git tag import odrive.version -version = odrive.version.get_version_str(git_only=creating_package, is_post_release=is_post_release) - -if creating_package and (hotfix > 0 or not version[-1].isdigit()): - # Add this for hotfixes - version += str(hotfix) +version = odrive.version.get_version_str( + git_only=creating_package, is_post_release=is_post_release, bump_rev=bump_rev ) # If we're currently creating the package we need to autogenerate # a file that contains the version string if creating_package: + if is_post_release: + version += str(post_rel_num) + elif (devnum > 0): + version += str(devnum) + version_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'odrive', 'version.txt') with open(version_file_path, mode='w') as version_file: version_file.write(version) @@ -98,7 +103,7 @@ setup( 'requests', # Used to by DFU to load firmware files 'IntelHex', # Used to by DFU to download firmware from github 'matplotlib', # Required to run the liveplotter - 'pywin32==222;platform_system=="Windows"' # Required for fancy terminal features on Windows + 'pywin32 >= 222; platform_system == "Windows"' # Required for fancy terminal features on Windows ], package_data={'': ['version.txt']}, classifiers = [],