From b073b038af3f57819c18b1757483443ffeb331b6 Mon Sep 17 00:00:00 2001 From: Benjamin Mako Hill Date: Thu, 6 Aug 2026 16:33:55 -0700 Subject: [PATCH] add --version and set the version to 0.3.0 wikiq had no way to report which version produced a dataset, which matters when output columns change between runs that end up in the same analysis. Add a --version flag, and print the version to stderr on every run so it lands in job logs alongside the output. 0.3.0 is the first release published anywhere. The earlier 0.1.1 and 0.2.0 tags were internal markers that were never released, so the version numbering starts being meaningful to users here. Co-Authored-By: Claude Opus 5 --- pyproject.toml | 2 +- src/wikiq/__init__.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f3cbfac..d56d85a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mediawiki-dump-tools" -version = "0.1.1" +version = "0.3.0" description = "Convert MediaWiki XML database dumps into tabular datasets for research" readme = "README.md" license = "GPL-3.0-or-later" diff --git a/src/wikiq/__init__.py b/src/wikiq/__init__.py index 3d0b7fe..b4f53b2 100755 --- a/src/wikiq/__init__.py +++ b/src/wikiq/__init__.py @@ -46,6 +46,13 @@ from wikiq.tables import RevisionTable from wikiq.wikitext_parser import WikitextParser from wikiq.resume import get_resume_point +try: + from importlib.metadata import PackageNotFoundError + from importlib.metadata import version as _package_version + __version__ = _package_version("mediawiki-dump-tools") +except PackageNotFoundError: + __version__ = "unknown" + TO_ENCODE = ("title", "editor") PERSISTENCE_RADIUS = 7 DIFF_TIMEOUT_MS = 60000 @@ -1134,6 +1141,12 @@ def main(): help="Output file or directory. Format is detected from extension: .jsonl for JSONL, otherwise TSV.", ) + parser.add_argument( + "--version", + action="version", + version=f"wikiq {__version__}", + ) + parser.add_argument( "-s", "--stdout", @@ -1391,6 +1404,7 @@ def main(): print(json.dumps(spark_schema, indent=2)) sys.exit(0) + print(f"wikiq {__version__}", file=sys.stderr) print(args, file=sys.stderr) if len(args.dumpfiles) > 0: for filename in args.dumpfiles: