File: get_version.py

package info (click to toggle)
systembridgemodels 5.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 808 kB
  • sloc: python: 1,855; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 708 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
"""Print the current package version from setup.py.

This script reads the version string from the repository's setup.py and prints
only the version to stdout.
"""

from __future__ import annotations

from pathlib import Path
import re


def main() -> None:
    """Print the current package version from setup.py."""
    project_root = Path(__file__).resolve().parents[1]
    setup_path = project_root / "setup.py"
    setup_contents = setup_path.read_text(encoding="utf-8")
    match = re.search(r'version="([^"]+)"', setup_contents)
    if not match:
        raise SystemExit("version field not found in setup.py")
    print(match.group(1))


if __name__ == "__main__":
    main()