dist: get commit from Ubuntu PPA directory name if no git information
This commit is contained in:
parent
934b486b13
commit
0547b1895a
12
setup.py
12
setup.py
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
from glob import glob as _glob
|
from glob import glob as _glob
|
||||||
|
|
||||||
|
@ -17,8 +20,13 @@ try:
|
||||||
commit = subprocess.check_output(['git', 'describe', '--always'], stderr=subprocess.DEVNULL).strip().decode()
|
commit = subprocess.check_output(['git', 'describe', '--always'], stderr=subprocess.DEVNULL).strip().decode()
|
||||||
with open('lib/solaar/commit', 'w') as vfile:
|
with open('lib/solaar/commit', 'w') as vfile:
|
||||||
vfile.write(f'{commit}\n')
|
vfile.write(f'{commit}\n')
|
||||||
except Exception:
|
except Exception: # get commit from Ubuntu PPA directory name
|
||||||
pass
|
dir = os.path.basename(sys.path[0])
|
||||||
|
print('DIRECTORY', dir)
|
||||||
|
commit_match = re.search(r'git[0-9]*-([0-9a-f]*)~', dir)
|
||||||
|
if commit_match:
|
||||||
|
with open('lib/solaar/commit', 'w') as vfile:
|
||||||
|
vfile.write(f'{version}-g{commit_match[1]}\n')
|
||||||
|
|
||||||
|
|
||||||
def _data_files():
|
def _data_files():
|
||||||
|
|
Loading…
Reference in New Issue