17
17
# under the License.
18
18
19
19
from pathlib import Path
20
- import tomllib
21
20
22
21
ROOT_DIR = Path (__file__ ).parent .parent
23
22
@@ -36,45 +35,3 @@ def list_packages():
36
35
37
36
38
37
PACKAGES = list_packages ()
39
-
40
- # package dependencies is used to maintain the dependencies between packages.
41
- #
42
- # All packages are depend on `core` by default, so we should only maintain the exceptions in list.
43
- PACKAGE_DEPENDENCIES = {
44
- Path ("bindings/go" ): "bindings/c" ,
45
- Path ("bindings/swift" ): "bindings/c" ,
46
- Path ("bindings/zig" ): "bindings/c" ,
47
- }
48
-
49
-
50
- # fetch the package dependence, return `core` if not listed in `PACKAGE_DEPENDENCIES`.
51
- def get_package_dependence (package : Path ) -> str :
52
- return PACKAGE_DEPENDENCIES .get (package , "core" )
53
-
54
-
55
- # input: Path to a Rust package like `core` and `bindings/python`.
56
- def get_rust_package_version (path ):
57
- with open (ROOT_DIR / path / "Cargo.toml" , "rb" ) as f :
58
- data = tomllib .load (f )
59
- version = data ["package" ]["version" ]
60
- return version
61
-
62
-
63
- # get the package version by package name.
64
- #
65
- # For examples:
66
- # core: `0.45.0`
67
- # packages depends on core: `0.1.0`
68
- def get_package_version (package ):
69
- if package == "core" :
70
- return get_rust_package_version ("core" )
71
-
72
- cargo_toml = ROOT_DIR / package / "Cargo.toml"
73
- # cargo_toml exists, we can get the version from Cargo.toml.
74
- if cargo_toml .exists ():
75
- return get_rust_package_version (package )
76
-
77
- # cargo_toml not exists, we should handle case by case ideally.
78
- #
79
- # However, those packages are not mature enough, it's much easier for us to always return `0.0.0` instead.
80
- return "0.0.0"
0 commit comments