Skip to content

Commit

Permalink
Use setuptools_scm for versioning
Browse files Browse the repository at this point in the history
Automatically generates the `usb.__version__` string on installation.

Closes #298.
  • Loading branch information
ap-- committed Jun 9, 2020
1 parent e3f3814 commit 25315d4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ MANIFEST
dist
.tox
*.egg-info
usb/_version.py
2 changes: 2 additions & 0 deletions pyproject.toml
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"]
3 changes: 3 additions & 0 deletions setup.cfg
@@ -1,2 +1,5 @@
[metadata]
description-file = README.rst

[options]
setup_requires = setuptools_scm
7 changes: 4 additions & 3 deletions setup.py
Expand Up @@ -32,12 +32,13 @@

from setuptools import setup

import usb


setup(
name='pyusb',
version=usb.__version__,
use_scm_version={
"version_scheme": "post-release",
"write_to": "usb/_version.py",
},
description='Python USB access module',
author='Robert Wlodarczyk',
author_email='robert@simplicityguy.com',
Expand Down
15 changes: 13 additions & 2 deletions usb/__init__.py
Expand Up @@ -48,8 +48,19 @@
__author__ = 'Wander Lairson Costa'

# Use Semantic Versioning, http://semver.org/
version_info = (1, 0, 2)
__version__ = '%d.%d.%d' % version_info
try:
from usb._version import version as __version__
except ImportError:
__version__ = '0.0.0'

def _get_version_info(version):
import re
m = re.match(r'(\d+)\.(\d+)\.(\d+)[.-]?(\D.*)?', version)
return tuple(
int(v) if v.isdigit() else v for v in m.groups() if v
)

version_info = _get_version_info(__version__)

__all__ = ['legacy', 'control', 'core', 'backend', 'util', 'libloader']

Expand Down

0 comments on commit 25315d4

Please sign in to comment.