lukasgeiter / mkdocs-awesome-pages-plugin

An MkDocs plugin that simplifies configuring page titles and their order
MIT License
452 stars 35 forks source link

Report module version within Python #72

Closed lofidevops closed 1 year ago

lofidevops commented 1 year ago

The module version is set in pyproject.toml, but cannot be accessed from within Python. This would be helpful for internal application reporting. A trivial use-case would be adding this value to a page footer.

This PR makes the version string accessible, for example:

import mkdocs-awesome-pages-plugin
print(mkdocs-awesome-pages-plugin.__version__)

In unusual, non-packaged environments, the version will be reported as "unknown".

lofidevops commented 1 year ago

Hmm. On second thoughts this is achievable with just:

from importlib.metadata import version
version("mkdocs-awesome-pages-plugin")