diff --git a/lib/solaar/__init__.py b/lib/solaar/__init__.py index d4a2c679..077a80ea 100644 --- a/lib/solaar/__init__.py +++ b/lib/solaar/__init__.py @@ -16,11 +16,15 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -__version_short__ = '1.1.7' -NAME = 'Solaar' +import subprocess as _subprocess +import sys as _sys + +from solaar.version import NAME as _NAME +from solaar.version import version as _version try: - import gitinfo - __version__ = __version_short__ + '-' + gitinfo.get_git_info()['commit'][:8] + __version__ = _subprocess.check_output(['git', 'describe', '--always'], cwd=_sys.path[0], + stderr=_subprocess.DEVNULL).strip().decode() except Exception: - __version__ = __version_short__ + __version__ = _version +NAME = _NAME diff --git a/lib/solaar/version.py b/lib/solaar/version.py new file mode 100644 index 00000000..be80b52f --- /dev/null +++ b/lib/solaar/version.py @@ -0,0 +1,2 @@ +NAME = 'Solaar' +version = '1.1.7-19-gcf26ac6e' diff --git a/setup.py b/setup.py index 4c197152..fb9bb28f 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +import subprocess + from glob import glob as _glob try: @@ -7,11 +9,16 @@ try: except ImportError: from distutils.core import setup -main_ns = {} -with open('lib/solaar/__init__.py') as ver_file: - exec(ver_file.read(), main_ns) -NAME = main_ns['NAME'] -__version__ = main_ns['__version_short__'] +NAME = 'Solaar' +version = '1.1.7' + +try: + cver = max(version, subprocess.check_output(['git', 'describe', '--always'], stderr=subprocess.DEVNULL).strip().decode()) +except Exception: + cver = version +with open('lib/solaar/version.py', 'w') as vfile: + vfile.write(f'NAME = \'{NAME}\'\n') + vfile.write(f'version = \'{cver}\'\n') def _data_files(): @@ -33,7 +40,7 @@ def _data_files(): setup( name=NAME.lower(), - version=__version__, + version=version, description='Linux device manager for Logitech receivers, keyboards, mice, and tablets.', long_description=''' Solaar is a Linux device manager for many Logitech peripherals that connect through