maloja/maloja/__pkginfo__.py

29 lines
824 B
Python
Raw Normal View History

2021-12-24 08:30:19 +03:00
# This file has now been slighly repurposed and will simply give other parts of
# the package access to some global meta-information about itself
2021-12-26 00:02:28 +03:00
try:
# from source
import toml
with open("./pyproject.toml") as filed:
metadata = toml.load(filed)['project']
2021-12-26 01:43:34 +03:00
VERSIONSTR = metadata['version']
HOMEPAGE = metadata['urls']['homepage']
except:
2021-12-26 22:22:17 +03:00
2021-12-26 01:43:34 +03:00
# package distributrion
2021-12-26 22:22:17 +03:00
from pkg_resources import get_distribution
pkg = get_distribution('maloja') # also contains a metadata
VERSIONSTR = pkg.version
#urls = metadata.metadata('maloja').get_all('Project-URL')
#urls = [e.split(', ') for e in urls]
#HOMEPAGE = [e[1] for e in urls if e[0] == 'homepage'][0]
# hardcode this for now
HOMEPAGE = "https://github.com/krateng/maloja"
2021-12-26 01:43:34 +03:00
VERSION = VERSIONSTR.split('.')
2020-03-06 19:06:08 +03:00
2021-12-26 01:43:34 +03:00
USER_AGENT = f"Maloja/{VERSIONSTR} ( {HOMEPAGE} )"