From db3480b688f12490d1769d896b5d0abe44893bec Mon Sep 17 00:00:00 2001 From: thebigmunch Date: Sun, 23 Feb 2020 18:40:44 -0500 Subject: [PATCH] Use importlib.metadata to dynamically populate module metadata --- pyproject.toml | 1 + src/google_music_scripts/__about__.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ad0af61..a73b15a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ flake8-builtins = { version = "^1.0", optional = true } flake8-comprehensions = { version = ">=2.0,<=4.0", optional = true } flake8-import-order = { version = "^0.18", optional = true } flake8-import-order-tbm = { version = "^1.0", optional = true } +importlib-metadata = { version = "^1.5.0", python = "<3.8", optional = true } nox = { version = "^2019", optional = true } sphinx = { version = "^2.0", optional = true} sphinx-argparse = { version = "^0.2", optional = true } diff --git a/src/google_music_scripts/__about__.py b/src/google_music_scripts/__about__.py index 3a7e908..4009029 100644 --- a/src/google_music_scripts/__about__.py +++ b/src/google_music_scripts/__about__.py @@ -10,15 +10,22 @@ '__version_info__', ] -__title__ = 'google-music-scripts' -__summary__ = 'A collection of scripts to interact with Google Music.' -__url__ = 'https://github.com/thebigmunch/google-music-scripts' +try: + from importlib.metadata import metadata +except ImportError: + from importlib_metadata import metadata -__version__ = '4.2.0' +meta = metadata('google-music-scripts') + +__title__ = meta['Name'] +__summary__ = meta['Summary'] +__url__ = meta['Home-page'] + +__version__ = meta['Version'] __version_info__ = tuple(int(i) for i in __version__.split('.') if i.isdigit()) -__author__ = 'thebigmunch' -__author_email__ = 'mail@thebigmunch.me' +__author__ = meta['Author'] +__author_email__ = meta['Author-email'] -__license__ = 'MIT' +__license__ = meta['License'] __copyright__ = f'2018-2020 {__author__} <{__author_email__}>'