dist: use git describe to get git version information

This commit is contained in:
Peter F. Patel-Schneider 2022-11-20 09:06:36 -05:00
parent 91b9a3a472
commit b5b6152e06
3 changed files with 24 additions and 11 deletions

View File

@ -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

2
lib/solaar/version.py Normal file
View File

@ -0,0 +1,2 @@
NAME = 'Solaar'
version = '1.1.7-19-gcf26ac6e'

View File

@ -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