forked from nod-ai/shark-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_local_version.py
executable file
·51 lines (35 loc) · 1.32 KB
/
compute_local_version.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# Copyright 2024 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# This scripts grabs the X.Y.Z[.dev]` version identifier from a
# `version.json` and writes the corresponding
# `X.Y.ZrcYYYYMMDD` version identifier to `version_local.json`.
import argparse
from pathlib import Path
import json
from datetime import datetime
from packaging.version import Version
parser = argparse.ArgumentParser()
parser.add_argument("path", type=Path)
args = parser.parse_args()
VERSION_FILE = args.path / "version.json"
VERSION_FILE_LOCAL = args.path / "version_local.json"
def load_version_info():
with open(VERSION_FILE, "rt") as f:
return json.load(f)
def write_version_info():
with open(VERSION_FILE_LOCAL, "w") as f:
json.dump(version_local, f, indent=2)
f.write("\n")
version_info = load_version_info()
PACKAGE_VERSION = version_info.get("package-version")
PACKAGE_BASE_VERSION = Version(PACKAGE_VERSION).base_version
PACKAGE_LOCAL_VERSION = (
PACKAGE_BASE_VERSION + "rc" + datetime.today().strftime("%Y%m%d")
)
version_local = {"package-version": PACKAGE_LOCAL_VERSION}
write_version_info()
print(PACKAGE_LOCAL_VERSION)