maloja/maloja/__pkginfo__.py

29 lines
950 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:37:14 +03:00
VERSION = metadata['version'] + "-dev"
2021-12-26 01:43:34 +03:00
HOMEPAGE = metadata['urls']['homepage']
2021-12-26 23:37:14 +03:00
# this will give wrong info when the installed package is run, but we just
# happen to be in the directory of the project
# but this can't be helped I think
2021-12-26 01:43:34 +03:00
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} )"