Skip to content

Commit bf48a48

Browse files
committed
WIP: buf build
1 parent 06ba299 commit bf48a48

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#### Start project specific git exclusions
22
otdf_python/
3+
build-scripts/buf-build/
34

45
#### End project specific git exclusions
56

build-scripts/buf.gen.python.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: v1
2+
managed:
3+
enabled: true
4+
plugins:
5+
- plugin: buf.build/grpc/python:v1.62.1
6+
out: gen
7+
- plugin: buf.build/protocolbuffers/python
8+
out: gen
9+
- plugin: buf.build/protocolbuffers/pyi:v26.1
10+
out: gen
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
set -x
4+
set -eou pipefail
5+
6+
loud_print(){
7+
printf """
8+
9+
========================================
10+
$1
11+
12+
13+
========================================
14+
15+
"""
16+
}
17+
18+
# Based on: https://stackoverflow.com/a/246128
19+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
20+
BUILD_ROOT="${SCRIPT_DIR}/buf-build"
21+
22+
# Cleanup previous builds
23+
rm -rf .venv-wheel/
24+
rm -rf .venv/
25+
rm -rf dist/
26+
rm -rf "${BUILD_ROOT}"
27+
28+
mkdir -p "${BUILD_ROOT}" || { echo "Unable to create build root directory" ; exit 1; }
29+
cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; }
30+
31+
SKIP_TESTS="${1:-NO}"
32+
33+
# Ensure 'buf' is installed
34+
if ! command -v buf &> /dev/null; then
35+
echo "[opentdf-python-sdk] buf could not be found, please install buf and retry."
36+
exit 1
37+
fi
38+
39+
# Ensure 'go' is installed
40+
if ! command -v go &> /dev/null; then
41+
echo "[opentdf-python-sdk] go could not be found, please install go and retry."
42+
exit 1
43+
fi
44+
45+
46+
# PY_TYPE="--python-preference=only-system"
47+
PY_TYPE="--python-preference=only-managed"
48+
49+
loud_print "Creating virtual environment"
50+
# Install python deps
51+
uv venv .venv --python 3.12 "$PY_TYPE"
52+
53+
if ! [ -d "${BUILD_ROOT}/.venv" ]; then
54+
echo "Unable to locate virtual environment directory"
55+
exit 1
56+
fi
57+
58+
loud_print "Activating virtual environment"
59+
source "${BUILD_ROOT}/.venv/bin/activate"
60+
61+
62+
# Shallow clone the 'https://github.com/opentdf/platform.git' repo
63+
git clone --depth 1 https://github.com/opentdf/platform.git
64+
65+
cd platform || { echo "Unable to change to platform directory" ; exit 1; }
66+
buf export --output=$BUILD_ROOT/protos --config buf.yaml

0 commit comments

Comments
 (0)