Skip to content

Commit

Permalink
debug: Never ever use packages from PyPI and only use existing matching
Browse files Browse the repository at this point in the history
versions for packages on conda-forge for protobuf 3

The protobuf 4 compilation will also be perform, but we ignore this
part for the moment just to be able to compile for 3 and see if this
works.
  • Loading branch information
jjerphan committed Jul 6, 2023
1 parent e4dcd61 commit 15bf7f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- doxygen
- grpcio
- grpcio-tools
- protobuf < 4
- protobuf==3.20.3
# Host dependencies
- boost-cpp
- krb5
Expand All @@ -26,7 +26,7 @@ dependencies:
- cyrus-sasl
- aws-sdk-cpp
- prometheus-cpp
- libprotobuf < 4
- libprotobuf==3.20.3
- bitmagic
- spdlog
# Incompatibility with fmt last version
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ install_requires =
pandas <2
attrs
dataclasses ; python_version < '3.7'
grpcio-tools
protobuf >=3.5.0.post1 # Per https://github.com/grpc/grpc/blob/v1.45.3/requirements.txt
xxhash
six
msgpack
Expand Down
32 changes: 7 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run(self):
output_dir = os.path.join(self.build_lib, "arcticdb", "proto")
python = sys.version_info[:2]
print(f"\nProtoc compilation (into '{output_dir}') for versions '{self.proto_vers}':")
for proto_ver in self.proto_vers:
for proto_ver in "3": # self.proto_vers:
if (python <= (3, 6) and proto_ver >= "4") or (python >= (3, 11) and proto_ver == "3"):
print(f"Python protobuf {proto_ver} do not run on Python {python}. Skipping...")
else:
Expand All @@ -67,35 +67,17 @@ def _compile_one_version(self, proto_ver: str, version_output_dir: str):
assert grpc_version, "Supported proto-vers arguments are " + ", ".join(self._PROTOBUF_TO_GRPC_VERSION)

# Manual virtualenv to avoid hard-coding Man internal locations
pythonpath = mkdtemp()
if not ARCTICDB_USING_CONDA:
# Python protobuf 3 and 4 are incompatible and we do not want to dictate which version of protobuf
# the user can have, so we compile the Python binding files with both versions and dynamically load
# the correct version at run time.
_log_and_run(
sys.executable,
"-mpip",
"install",
"--disable-pip-version-check",
"--target=" + pythonpath,
"grpcio-tools" + grpc_version,
f"protobuf=={proto_ver}.*",
)
env = {**os.environ, "PYTHONPATH": pythonpath, "PYTHONNOUSERSITE": "1"}
# Using protoc of grpcio-tools installed in the environment from PyPI.
cmd = [sys.executable, "-mgrpc_tools.protoc", "-Icpp/proto", "--python_out=" + version_output_dir]
else:
# grpcio-tools and protobuf already are installed in the conda environment (see environment.yml)
# Using protoc installed in the conda environment from conda-forge.
env = {**os.environ}
cmd = ["protoc", "-Icpp/proto", "--python_out=" + version_output_dir]
# grpcio-tools and protobuf already are installed in the conda environment (see environment.yml)
# Using protoc installed in the conda environment from conda-forge.
env = {**os.environ}
cmd = ["protoc", "--version"]
_log_and_run(*cmd, env=env)

# Compile
cmd = ["protoc", "-Icpp/proto", "--python_out=" + version_output_dir]
os.makedirs(version_output_dir, exist_ok=True)
_log_and_run(*cmd, *glob.glob(os.path.normpath("cpp/proto/arcticc/pb2/*.proto")), env=env)

shutil.rmtree(pythonpath)


class CompileProtoAndBuild(build_py):
def run(self):
Expand Down

0 comments on commit 15bf7f9

Please sign in to comment.