Skip to content

Commit 7ea15b3

Browse files
authored
feat: add support for proto.__version__ (#393)
1 parent a86e311 commit 7ea15b3

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

packages/proto-plus/proto/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .message import Message
2121
from .modules import define_module as module
2222
from .primitives import ProtoType
23+
from .version import __version__
2324

2425

2526
DOUBLE = ProtoType.DOUBLE
@@ -42,6 +43,7 @@
4243

4344

4445
__all__ = (
46+
"__version__",
4547
"Enum",
4648
"Field",
4749
"MapField",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2023 Google LLC
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+
__version__ = "1.22.3"

packages/proto-plus/setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
# limitations under the License.
1414

1515
import io
16+
import re
1617
import os
1718

1819
from setuptools import find_packages, setup
1920

20-
version = "1.22.3"
21-
2221
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))
2322

23+
version = None
24+
25+
with open(os.path.join(PACKAGE_ROOT, "proto/version.py")) as fp:
26+
version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read())
27+
assert len(version_candidates) == 1
28+
version = version_candidates[0]
29+
2430
with io.open(os.path.join(PACKAGE_ROOT, "README.rst")) as file_obj:
2531
README = file_obj.read()
2632

0 commit comments

Comments
 (0)