1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 17:12:21 +03:00

Merge pull request #1200 from A-UNDERSCORE-D/fix/967/Only-read-from-gitversion-once-per-run

Cache appversion when it is created
This commit is contained in:
Athanasius 2021-07-29 15:12:36 +01:00 committed by GitHub
commit d2d0aad425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@ appcmdname = 'EDMC'
# Major.Minor.Patch(-prerelease)(+buildmetadata)
# NB: Do *not* import this, use the functions appversion() and appversion_nobuild()
_static_appversion = '5.1.2-beta0'
_cached_version: Optional[semantic_version.Version] = None
copyright = '© 2015-2019 Jonathan Harris, 2020-2021 EDCD'
update_feed = 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
@ -138,6 +139,10 @@ def appversion() -> semantic_version.Version:
:return: The augmented app version.
"""
global _cached_version
if _cached_version is not None:
return _cached_version
if getattr(sys, 'frozen', False):
# Running frozen, so we should have a .gitversion file
# Yes, .parent because if frozen we're inside library.zip
@ -150,7 +155,8 @@ def appversion() -> semantic_version.Version:
if shorthash is None:
shorthash = 'UNKNOWN'
return semantic_version.Version(f'{_static_appversion}+{shorthash}')
_cached_version = semantic_version.Version(f'{_static_appversion}+{shorthash}')
return _cached_version
def appversion_nobuild() -> semantic_version.Version: