-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_version.py
More file actions
34 lines (27 loc) · 999 Bytes
/
set_version.py
File metadata and controls
34 lines (27 loc) · 999 Bytes
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
29
30
31
32
33
34
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: disable=W0102,E0712,C0103,R0903
"""World Radio Prefixes - RCLDX companion software"""
__updated__ = "2025-12-08 13:41:08"
import re
from pathlib import Path
init_file = next(Path("src").glob("*/__init__.py"))
pyproject_file = Path("pyproject.toml")
# Read the version from __init__.py
try:
version_match = re.search(r'__version__ = "(.*?)"', init_file.read_text())
except FileNotFoundError:
print(f"{init_file} not found")
exit(1)
# -- Update version in pyproject.toml
if version_match:
version = version_match.group(1)
# Update version in pyproject.toml
try:
pyproject_content = pyproject_file.read_text()
except FileNotFoundError:
print(f"{pyproject_file} not found")
exit(1)
pyproject_content = re.sub(r'version = "(.*?)"', f'version = "{version}"', pyproject_content)
pyproject_file.write_text(pyproject_content)
print(f"Updated pyproject.toml version to {version}")