-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathupdate_substrait.py
48 lines (34 loc) · 1.56 KB
/
update_substrait.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Requires protoc 3.19.04
# https://github.com/protocolbuffers/protobuf/releases/tag/v3.19.4
import os
import shutil
from os import walk
GITHUB_TAG = "a64a1025280d89bddb8983438ce9dda99ac4b05e" # v0.61.0
# Change to substrait folder
sub_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)),'..','third_party','substrait')
os.chdir(sub_folder)
# Delete Current CPP files
shutil.rmtree(os.path.join(sub_folder,'substrait'))
# Clone Proto Files
os.system("git clone https://github.com/substrait-io/substrait git-sub")
git_folder = os.path.join(sub_folder,'git-sub')
# Generate Proto Files on a specific git tag
os.chdir(git_folder)
os.system("git checkout " + GITHUB_TAG)
os.chdir(sub_folder)
proto_folder = os.path.join(git_folder,'proto')
substrait_proto_folder = os.path.join(proto_folder,'substrait')
substrait_extensions_proto_folder = os.path.join(substrait_proto_folder,'extensions')
os.mkdir("substrait")
os.mkdir("substrait/extensions")
# Generate all files
proto_sub_list = next(walk(substrait_proto_folder), (None, None, []))[2]
proto_sub_extensions = next(walk(substrait_extensions_proto_folder), (None, None, []))[2]
# /usr/local/bin/protoc
print("Protoc version" + os.popen('protoc --version').read())
for proto in proto_sub_list:
os.system("protoc -I="+ proto_folder+ " --cpp_out="+sub_folder +" "+ os.path.join(substrait_proto_folder,proto))
for proto in proto_sub_extensions:
os.system("protoc -I="+ proto_folder+ " --cpp_out="+sub_folder +" "+ os.path.join(substrait_extensions_proto_folder,proto))
# Delete Git Folder
shutil.rmtree(git_folder)