better version handling

This commit is contained in:
Oskar Weigl
2018-06-21 16:37:58 -07:00
parent 0ff88ea97b
commit 1774e88b30
2 changed files with 18 additions and 11 deletions
+3 -1
View File
@@ -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"
+15 -10
View File
@@ -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 = [],