Skip to content

Commit

Permalink
improve pip setup version handling and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
madcowswe committed Jul 2, 2018
1 parent 174be01 commit 3e1cfca
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 34 deletions.
4 changes: 2 additions & 2 deletions tools/odrive/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, bump_rev=False):
def get_version_str(git_only=False, is_post_release=False, bump_rev=False, release_override=False):
"""
Returns the versions of the tools
If git_only is true, the version.txt file is ignored even
Expand All @@ -57,7 +57,7 @@ def get_version_str(git_only=False, is_post_release=False, bump_rev=False):
version = '{}.{}.{}'.format(major, minor, revision)
if is_post_release:
version += ".post"
elif unreleased:
elif not release_override and unreleased:
version += ".dev"
return version

Expand Down
72 changes: 40 additions & 32 deletions tools/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@
to publish packages with the name odrive.
"""

# Set to true to make the current release
is_release = False

# Set to true to make an official post-release, rather than dev of new version
is_post_release = False
post_rel_num = 0

# To test higher numbered releases, bump to the next rev
bump_rev = not is_post_release
devnum = 0
bump_rev = not is_post_release and not is_release

# TODO: add additional y/n prompt to prevent from erroneous upload

Expand All @@ -50,7 +53,10 @@
# Load version from Git tag
import odrive.version
version = odrive.version.get_version_str(
git_only=creating_package, is_post_release=is_post_release, bump_rev=bump_rev )
git_only=creating_package,
is_post_release=is_post_release,
bump_rev=bump_rev,
release_override=is_release)

# If we're currently creating the package we need to autogenerate
# a file that contains the version string
Expand Down Expand Up @@ -85,33 +91,35 @@
except PermissionError:
print("Warning: could not set up udev rules. Run `sudo odrivetool udev-setup` to try again.")

setup(
name = 'odrive',
packages = ['odrive', 'odrive.dfuse', 'fibre'],
scripts = ['odrivetool', 'odrivetool.bat', 'odrive_demo.py'],
version = version,
description = 'Control utilities for the ODrive high performance motor controller',
author = 'Oskar Weigl',
author_email = 'oskar.weigl@odriverobotics.com',
license='MIT',
url = 'https://github.com/madcowswe/ODrive',
keywords = ['odrive', 'motor', 'motor control'],
install_requires = [
'ipython', # Used to do the interactive parts of the odrivetool
'PyUSB', # Required to access USB devices from Python through libusb
'PySerial', # Required to access serial devices from Python
'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
],
package_data={'': ['version.txt']},
classifiers = [],
)

# TODO: include README

# clean up
if creating_package:
os.remove(version_file_path)
os.remove(fibre_link)
try:
setup(
name = 'odrive',
packages = ['odrive', 'odrive.dfuse', 'fibre'],
scripts = ['odrivetool', 'odrivetool.bat', 'odrive_demo.py'],
version = version,
description = 'Control utilities for the ODrive high performance motor controller',
author = 'Oskar Weigl',
author_email = 'oskar.weigl@odriverobotics.com',
license='MIT',
url = 'https://github.com/madcowswe/ODrive',
keywords = ['odrive', 'motor', 'motor control'],
install_requires = [
'ipython', # Used to do the interactive parts of the odrivetool
'PyUSB', # Required to access USB devices from Python through libusb
'PySerial', # Required to access serial devices from Python
'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
],
package_data={'': ['version.txt']},
classifiers = [],
)

# TODO: include README

finally:
# clean up
if creating_package:
os.remove(version_file_path)
os.remove(fibre_link)

0 comments on commit 3e1cfca

Please sign in to comment.