Skip to content

Commit f7585fe

Browse files
committed
Add version.py and ai_edge_torch.__version__ (#123)
* add version.py * Update setup.py
1 parent 4c40530 commit f7585fe

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

ai_edge_torch/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .convert.converter import signature
1818
from .convert.to_channel_last_io import to_channel_last_io
1919
from .model import Model
20+
from .version import __version__
2021

2122

2223
def load(path: str) -> Model:

ai_edge_torch/version.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 The AI Edge Torch Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
16+
__version__ = "0.2.0"

setup.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import os
1717
import pathlib
18+
import re
1819

1920
from setuptools import find_packages
2021
from setuptools import setup
@@ -33,11 +34,19 @@
3334
""".lstrip()
3435

3536
name = "ai-edge-torch"
36-
version = "0.2.0"
37+
# TODO(b/357076369): move version updating logics to version.py
38+
version_py = here / "ai_edge_torch" / "version.py"
39+
version_regex = "__version__\s*=\s*(\"|')(?P<version>[^\"']+)(\"|')"
40+
version = re.search(version_regex, version_py.read_text()).group("version")
41+
3742
if nightly_release_date := os.environ.get("NIGHTLY_RELEASE_DATE"):
3843
name += "-nightly"
3944
version += ".dev" + nightly_release_date
40-
45+
version_py.write_text(
46+
re.sub(
47+
version_regex, f'__version__ = "{version}"', version_py.read_text()
48+
)
49+
)
4150

4251
setup(
4352
name=name,

0 commit comments

Comments
 (0)