maloja/maloja/__pkginfo__.py

26 lines
781 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 23:36:36 +03:00
VERSION = metadata['version']
2021-12-26 01:43:34 +03:00
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
2021-12-26 23:36:36 +03:00
VERSION = pkg.version
2021-12-26 22:22:17 +03:00
#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
2021-12-26 23:36:36 +03:00
USER_AGENT = f"Maloja/{VERSION} ( {HOMEPAGE} )"