diff options
author | Matt Clay <matt@mystile.com> | 2023-03-28 17:00:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 17:00:12 -0700 |
commit | 0cfdf0ad59689ce9b149e8d56b4e30bc876398b6 (patch) | |
tree | 3303d2de6b227e156d21225c892d193fc9b6cf73 | |
parent | 46362bbd2783d25ddc1edaaf4db7d00627ad7e88 (diff) | |
download | ansible-0cfdf0ad59689ce9b149e8d56b4e30bc876398b6.tar.gz |
Use a dedicated version helper for the docs build (#80345)
This removes the dependency on the release version helper in the docs-build sanity test.
-rw-r--r-- | docs/docsite/Makefile | 4 | ||||
-rw-r--r-- | docs/docsite/version_helper.py | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/docs/docsite/Makefile b/docs/docsite/Makefile index f8e8759098..961f7343cf 100644 --- a/docs/docsite/Makefile +++ b/docs/docsite/Makefile @@ -46,12 +46,12 @@ DOC_PLUGINS ?= become cache callback cliconf connection httpapi inventory lookup PYTHON ?= python # fetch version from project release.py as single source-of-truth -VERSION := $(shell $(PYTHON) ../../packaging/release/versionhelper/version_helper.py --raw || echo error) +VERSION := $(shell $(PYTHON) ./version_helper.py --raw || echo error) ifeq ($(findstring error,$(VERSION)), error) $(error "version_helper failed") endif -MAJOR_VERSION := $(shell $(PYTHON) ../../packaging/release/versionhelper/version_helper.py --majorversion || echo error) +MAJOR_VERSION := $(shell $(PYTHON) ./version_helper.py --majorversion || echo error) ifeq ($(findstring error,$(MAJOR_VERSION)), error) $(error "version_helper failed to determine major version") endif diff --git a/docs/docsite/version_helper.py b/docs/docsite/version_helper.py new file mode 100644 index 0000000000..562b947b93 --- /dev/null +++ b/docs/docsite/version_helper.py @@ -0,0 +1,30 @@ +"""Simple helper for printing ansible-core version numbers.""" +import argparse +import pathlib +import sys + +from packaging.version import Version + + +def main() -> None: + """Main program entry point.""" + parser = argparse.ArgumentParser(description=__doc__) + group = parser.add_mutually_exclusive_group() + group.add_argument('--raw', action='store_true') + group.add_argument('--majorversion', action='store_true') + args = parser.parse_args() + + sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent.parent / 'lib')) + + from ansible.release import __version__ + + version = Version(__version__) + + if args.raw: + print(version) + elif args.majorversion: + print(f'{version.major}.{version.minor}') + + +if __name__ == '__main__': + main() |