Skip to content

Commit

Permalink
Upgrade to Protobuf 5 (#1635)
Browse files Browse the repository at this point in the history
Implements #1422 for pip wheels.

#### Checklist

<details>
  <summary>
   Checklist for code changes...
  </summary>
 
- [ ] Have you updated the relevant docstrings, documentation and
copyright notice?
- [ ] Is this contribution tested against [all ArcticDB's
features](../docs/mkdocs/docs/technical/contributing.md)?
- [ ] Do all exceptions introduced raise appropriate [error
messages](https://docs.arcticdb.io/error_messages/)?
 - [ ] Are API changes highlighted in the PR description?
- [ ] Is the PR labelled as enhancement or bug so it appears in
autogenerated release notes?
</details>

<!--
Thanks for contributing a Pull Request to ArcticDB! Please ensure you
have taken a look at:
- ArcticDB's Code of Conduct:
https://github.com/man-group/ArcticDB/blob/master/CODE_OF_CONDUCT.md
- ArcticDB's Contribution Licensing:
https://github.com/man-group/ArcticDB/blob/master/docs/mkdocs/docs/technical/contributing.md#contribution-licensing
-->
  • Loading branch information
muhammadhamzasajjad authored Jul 3, 2024
1 parent 31853f1 commit 66a5d19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion python/arcticc/pb2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import google.protobuf as _protobuf

_proto_ver = _protobuf.__version__.split(".")[0]
if _proto_ver in "34":
if _proto_ver in "345":

_python = _sys.version_info[:2]
if _python >= (3, 11) and _proto_ver == "3":
Expand All @@ -19,6 +19,12 @@
"We recommend updating your environment to use the minimum supported version of Python.\n"
"For more information, see: https://devguide.python.org/versions/#supported-versions"
)
elif _python <= (3, 7) and _proto_ver >= "5":
raise RuntimeError(
"Your environment uses protobuf 5 which does not support Python<=3.7.\n"
"We recommend updating your environment to use the minimum supported version of Python.\n"
"For more information, see: https://devguide.python.org/versions/#supported-versions"
)

# Use the namespace package (https://peps.python.org/pep-0420) feature to select the pb2 files matching the protobuf
_protos_path = _os.path.abspath(
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install_requires =
pandas
attrs
dataclasses ; python_version < '3.7'
protobuf >=3.5.0.post1, < 5 # Per https://github.com/grpc/grpc/blob/v1.45.3/requirements.txt
protobuf >=3.5.0.post1 # Per https://github.com/grpc/grpc/blob/v1.45.3/requirements.txt
msgpack >=0.5.0 # msgpack 0.5.0 is required for strict_types argument, needed for correct pickling fallback

pyyaml
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _log_and_run(*cmd, **kwargs):

class CompileProto(Command):
# When adding new protobuf versions, also update: setup.cfg, python/arcticdb/__init__.py
_PROTOBUF_TO_GRPC_VERSION = {"3": "<=1.30.*", "4": ">=1.49"}
_PROTOBUF_TO_GRPC_VERSION = {"3": "<=1.30.*", "4": ">=1.49", "5": ">=1.64"}

description = '"protoc" generate code _pb2.py from .proto files'
user_options = [
Expand Down Expand Up @@ -70,6 +70,10 @@ def run(self):
# No available on PyPI for this configuration
# See the first release's: https://pypi.org/project/protobuf/4.21.1/#files
print(f"Python protobuf {proto_ver} do not run on Python {python}. Skipping...")
elif not ARCTICDB_USING_CONDA and python <= (3, 7) and proto_ver >= "5":
# Not compatible with Python<=3.7 as
# GRPCIO >= 1.64.0 is not available on Python<=3.7 https://pypi.org/project/grpcio-tools/1.64.0/#files
print(f"Python protobuf {proto_ver} does not run on Python {python}. Skipping...")
else:
self._compile_one_version(proto_ver, os.path.join(output_dir, proto_ver))

Expand Down

0 comments on commit 66a5d19

Please sign in to comment.