|
1 | 1 | #!/bin/bash |
2 | 2 |
|
| 3 | +# Based on the excellent work of the sift-stack team: |
| 4 | +# https://github.com/sift-stack/sift/blob/main/docs/python.md |
3 | 5 | set -x |
4 | 6 | set -eou pipefail |
5 | 7 |
|
@@ -43,12 +45,29 @@ if ! command -v go &> /dev/null; then |
43 | 45 | fi |
44 | 46 |
|
45 | 47 |
|
| 48 | +# Shallow clone the 'https://github.com/opentdf/platform.git' repo |
| 49 | +git clone --depth 1 https://github.com/opentdf/platform.git |
| 50 | + |
| 51 | +cd platform || { echo "Unable to change to platform directory" ; exit 1; } |
| 52 | +buf export --output=$BUILD_ROOT/protos --config buf.yaml |
| 53 | + |
| 54 | +cd $SCRIPT_DIR || { echo "Unable to change to script directory" ; exit 1; } |
| 55 | +cp buf.gen.python.yaml $BUILD_ROOT/buf.gen.yaml |
| 56 | +cp setup.py $BUILD_ROOT/setup.py |
| 57 | + |
| 58 | +cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; } |
| 59 | +buf generate protos || { echo "buf generate failed" ; exit 1; } |
| 60 | + |
| 61 | +for dir in $(find gen -type d); do |
| 62 | + touch $dir/__init__.py |
| 63 | +done |
| 64 | + |
46 | 65 | # PY_TYPE="--python-preference=only-system" |
47 | 66 | PY_TYPE="--python-preference=only-managed" |
48 | 67 |
|
49 | 68 | loud_print "Creating virtual environment" |
50 | 69 | # Install python deps |
51 | | -uv venv .venv --python 3.12 "$PY_TYPE" |
| 70 | +uv venv .venv "$PY_TYPE" |
52 | 71 |
|
53 | 72 | if ! [ -d "${BUILD_ROOT}/.venv" ]; then |
54 | 73 | echo "Unable to locate virtual environment directory" |
|
58 | 77 | loud_print "Activating virtual environment" |
59 | 78 | source "${BUILD_ROOT}/.venv/bin/activate" |
60 | 79 |
|
| 80 | +uv pip install build protobuf grpcio |
| 81 | +python -m build --sdist || { echo "Failed to build source distribution" ; exit 1; } |
| 82 | +python -m build --wheel || { echo "Failed to build wheel distribution" ; exit 1; } |
61 | 83 |
|
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 |
| 84 | +echo "Build completed successfully." |
| 85 | +echo "Directory contents:" |
| 86 | +ls -lart |
| 87 | +echo "Dist directory contents:" |
| 88 | +ls -lart dist/ |
0 commit comments