Skip to content

Commit 82c804a

Browse files
authored
feat: remove generated protobuf code from substrait-python (#145)
Generation of protobuf bindings has been extracted to the substrait-protobuf package. BREAKING CHANGE: code under `substrait.gen.proto` is now found under `substrait` BREAKING CHANGE: simple extension files have been moved from `extensions` to `extension_files` BREAKING CHANGE: version information has been moved to `substrait.version` module
1 parent 0b75583 commit 82c804a

File tree

96 files changed

+242
-8833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+242
-8833
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ You can run the full code generation using the following command or use the indi
3737
pixi run codegen
3838
```
3939

40-
## Protobuf stubs
40+
## Extension Copying
4141

42-
Run the proto codegen only:
42+
Copy the core function extensions into substrait-python
4343

4444
```
45-
pixi run codegen-proto
45+
pixi run copy-extensions
4646
```
4747

4848
## Antlr grammar

buf.gen.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

buf.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

copy_extension_yamls.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
submodule_dir=./third_party/substrait
6+
extension_dir=./src/substrait/extension_files
7+
8+
# Remove the old extension files
9+
rm -rf "$extension_dir"
10+
11+
# Copy over new yaml files
12+
cp -fr "$submodule_dir"/extensions "$extension_dir"
13+
find "$extension_dir" -type f -exec chmod u+rw {} +
14+
15+
# Ensure there's an __init__.py file in the extension directory
16+
touch $extension_dir/__init__.py

examples/builder_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import substrait.gen.proto.algebra_pb2 as stalg
1+
import substrait.algebra_pb2 as stalg
2+
23
from substrait.builders.extended_expression import (
34
column,
45
literal,

gen_proto.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

pixi.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ authors = [{name = "Substrait contributors", email = "substrait@googlegroups.com
55
license = {text = "Apache-2.0"}
66
readme = "README.md"
77
requires-python = ">=3.10,<3.14"
8-
dependencies = ["protobuf >=5,<7"]
8+
dependencies = [
9+
"protobuf >=5,<7",
10+
"substrait-protobuf==0.79.0",
11+
]
912
dynamic = ["version"]
1013

1114
[tool.setuptools_scm]
@@ -53,11 +56,11 @@ update-substrait = [ { task = "update-submodule" }, { task = "codegen" }]
5356

5457
update-submodule = "./update_submodule.sh"
5558

56-
codegen = [{ task = "antlr" }, { task = "codegen-proto" }, { task = "codegen-extensions" }]
59+
codegen = [{ task = "antlr" }, { task = "copy-extensions" }, { task = "codegen-extensions" }]
5760

5861
check-codegen = "./check_codegen.sh"
5962

60-
codegen-proto = "./gen_proto.sh"
63+
copy-extensions = "./copy_extension_yamls.sh"
6164

6265
antlr = """
6366
cd third_party/substrait/grammar \

src/substrait/__init__.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/substrait/builders/extended_expression.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
from datetime import date
33
from typing import Any, Callable, Iterable, Union
44

5-
import substrait.gen.proto.algebra_pb2 as stalg
6-
import substrait.gen.proto.extended_expression_pb2 as stee
7-
import substrait.gen.proto.extensions.extensions_pb2 as ste
8-
import substrait.gen.proto.type_pb2 as stp
5+
import substrait.algebra_pb2 as stalg
6+
import substrait.extended_expression_pb2 as stee
7+
import substrait.extensions.extensions_pb2 as ste
8+
import substrait.type_pb2 as stp
9+
910
from substrait.extension_registry import ExtensionRegistry
1011
from substrait.type_inference import infer_extended_expression_schema
1112
from substrait.utils import (

0 commit comments

Comments
 (0)