| 1 |
|
| 2 |
|
| 3 |
import os |
| 4 |
import re |
| 5 |
import subprocess |
| 6 |
|
| 7 |
tag = subprocess.run(['git', 'describe', '--tags'], |
| 8 |
capture_output=True, check=True, |
| 9 |
text=True).stdout.strip() |
| 10 |
|
| 11 |
|
| 12 |
version = tag.strip("v").split('-', 1)[0] |
| 13 |
|
| 14 |
init_path = os.path.join(os.path.dirname(__file__), '..', 'awscrt', '__init__.py') |
| 15 |
print("Updating awscrt.__version__ to version {}".format(version)) |
| 16 |
contents = None |
| 17 |
with open(init_path, 'r+') as init_py: |
| 18 |
contents = init_py.read() |
| 19 |
|
| 20 |
contents = re.sub(r"__version__ = '[^']+'", f"__version__ = '{version}'", contents) |
| 21 |
|
| 22 |
with open(init_path, 'w') as init_py: |
| 23 |
init_py.write(contents) |