mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-04 19:40:02 +03:00
app version: Write a .gitversion file with short hash from setup.py
This commit is contained in:
parent
8b3294ecdd
commit
3f3a4f282e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.gitversion
|
||||
.DS_Store
|
||||
build
|
||||
dist.*
|
||||
|
@ -9,6 +9,7 @@ found necessary to move out of other files.
|
||||
# config.py
|
||||
appname = 'EDMarketConnector'
|
||||
applongname = 'E:D Market Connector'
|
||||
GITVERSION_FILE = '.gitversion'
|
||||
|
||||
# protocol.py
|
||||
protocolhandler_redirect = 'edmc://auth'
|
||||
|
25
setup.py
25
setup.py
@ -12,6 +12,7 @@ import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from distutils.core import setup
|
||||
from os.path import exists, isdir, join
|
||||
@ -21,10 +22,34 @@ from typing import Any, Generator, Set
|
||||
import semantic_version
|
||||
|
||||
from config import appcmdname, applongname, appname, appversion, copyright, update_feed, update_interval
|
||||
from constants import GITVERSION_FILE
|
||||
|
||||
if sys.version_info[0:2] != (3, 9):
|
||||
raise AssertionError(f'Unexpected python version {sys.version}')
|
||||
|
||||
# Retrieve current git short hash and store in file GITVERSION_FILE
|
||||
try:
|
||||
git_cmd = subprocess.Popen('git rev-parse --short HEAD'.split(),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT
|
||||
)
|
||||
out, err = git_cmd.communicate()
|
||||
|
||||
except Exception as e:
|
||||
print(f"Couldn't run git command for short hash: {e!r}")
|
||||
exit(-1)
|
||||
|
||||
else:
|
||||
git_shorthash: str = out.decode().rstrip('\n')
|
||||
if re.match(r'^[0-9a-f]{7,}$', git_shorthash) is None:
|
||||
print(f"'{git_shorthash}' doesn't look like a valid git short hash!")
|
||||
exit(-2)
|
||||
|
||||
with open(GITVERSION_FILE, 'w+', encoding='utf-8') as gvf:
|
||||
gvf.write(git_shorthash)
|
||||
|
||||
print(f'Git short hash: {git_shorthash}')
|
||||
|
||||
if sys.platform == 'win32':
|
||||
assert platform.architecture()[0] == '32bit', 'Assumes a Python built for 32bit'
|
||||
import py2exe # noqa: F401 # Yes, this *is* used
|
||||
|
Loading…
x
Reference in New Issue
Block a user