From bf48a48b0bce85cb2e93bf4dc423c22e9bc17568 Mon Sep 17 00:00:00 2001 From: b-long Date: Fri, 2 May 2025 17:37:44 -0400 Subject: [PATCH 1/4] WIP: buf build --- .gitignore | 1 + build-scripts/buf.gen.python.yaml | 10 +++++ build-scripts/uv_buf_build_script.sh | 66 ++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 build-scripts/buf.gen.python.yaml create mode 100755 build-scripts/uv_buf_build_script.sh diff --git a/.gitignore b/.gitignore index b8e2ea4..89e08d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ #### Start project specific git exclusions otdf_python/ +build-scripts/buf-build/ #### End project specific git exclusions diff --git a/build-scripts/buf.gen.python.yaml b/build-scripts/buf.gen.python.yaml new file mode 100644 index 0000000..61672f8 --- /dev/null +++ b/build-scripts/buf.gen.python.yaml @@ -0,0 +1,10 @@ +version: v1 +managed: + enabled: true +plugins: + - plugin: buf.build/grpc/python:v1.62.1 + out: gen + - plugin: buf.build/protocolbuffers/python + out: gen + - plugin: buf.build/protocolbuffers/pyi:v26.1 + out: gen diff --git a/build-scripts/uv_buf_build_script.sh b/build-scripts/uv_buf_build_script.sh new file mode 100755 index 0000000..4aa5169 --- /dev/null +++ b/build-scripts/uv_buf_build_script.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -x +set -eou pipefail + +loud_print(){ + printf """ + + ======================================== + $1 + + + ======================================== + + """ +} + +# Based on: https://stackoverflow.com/a/246128 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +BUILD_ROOT="${SCRIPT_DIR}/buf-build" + +# Cleanup previous builds +rm -rf .venv-wheel/ +rm -rf .venv/ +rm -rf dist/ +rm -rf "${BUILD_ROOT}" + +mkdir -p "${BUILD_ROOT}" || { echo "Unable to create build root directory" ; exit 1; } +cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; } + +SKIP_TESTS="${1:-NO}" + +# Ensure 'buf' is installed +if ! command -v buf &> /dev/null; then + echo "[opentdf-python-sdk] buf could not be found, please install buf and retry." + exit 1 +fi + +# Ensure 'go' is installed +if ! command -v go &> /dev/null; then + echo "[opentdf-python-sdk] go could not be found, please install go and retry." + exit 1 +fi + + +# PY_TYPE="--python-preference=only-system" +PY_TYPE="--python-preference=only-managed" + +loud_print "Creating virtual environment" +# Install python deps +uv venv .venv --python 3.12 "$PY_TYPE" + +if ! [ -d "${BUILD_ROOT}/.venv" ]; then + echo "Unable to locate virtual environment directory" + exit 1 +fi + +loud_print "Activating virtual environment" +source "${BUILD_ROOT}/.venv/bin/activate" + + +# Shallow clone the 'https://github.com/opentdf/platform.git' repo +git clone --depth 1 https://github.com/opentdf/platform.git + +cd platform || { echo "Unable to change to platform directory" ; exit 1; } +buf export --output=$BUILD_ROOT/protos --config buf.yaml From 6a82f767de57d63dfd4fa9525a75b91683d964e1 Mon Sep 17 00:00:00 2001 From: b-long Date: Fri, 2 May 2025 17:44:31 -0400 Subject: [PATCH 2/4] WIP: buf build --- .github/workflows/build-golang-macos.yaml | 50 ---- .../workflows/build-golang-ubuntu-buf.yaml | 55 ++++ .github/workflows/build-golang-ubuntu.yaml | 65 ----- .python-version | 1 - .../buf.gen.python.yaml | 0 buf-build/list_wheel_modules.py | 77 +++++ buf-build/setup.py | 11 + .../uv_buf_build_script.sh | 50 +++- build-scripts/docker-compose.yml | 276 ++++++++++++++++++ setup.py | 30 -- setup_ci.py | 105 ------- 11 files changed, 463 insertions(+), 257 deletions(-) delete mode 100644 .github/workflows/build-golang-macos.yaml create mode 100644 .github/workflows/build-golang-ubuntu-buf.yaml delete mode 100644 .github/workflows/build-golang-ubuntu.yaml delete mode 100644 .python-version rename {build-scripts => buf-build}/buf.gen.python.yaml (100%) create mode 100644 buf-build/list_wheel_modules.py create mode 100644 buf-build/setup.py rename {build-scripts => buf-build}/uv_buf_build_script.sh (50%) create mode 100644 build-scripts/docker-compose.yml delete mode 100644 setup.py delete mode 100644 setup_ci.py diff --git a/.github/workflows/build-golang-macos.yaml b/.github/workflows/build-golang-macos.yaml deleted file mode 100644 index 4585c5c..0000000 --- a/.github/workflows/build-golang-macos.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: macOS build - -on: [push] - -defaults: - run: - shell: bash - -jobs: - call-lint: - uses: ./.github/workflows/lint-on-macos.yaml - - build: - runs-on: macos-13 - permissions: - contents: write - - strategy: - fail-fast: true - matrix: - go-version: [1.22.x] - python3_version: [ "3.11", "3.12" ] - - steps: - - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - cache-dependency-path: go.sum - - name: Install dependencies - run: go get . - - name: Test with Go - run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python3_version }} - - # FIXME: Add more caching - - name: Configure gopy / dependencies, and build wheel - run: | - ./build-scripts/ci-build.sh - - # - uses: ./.github/workflows/platform-integration-test.yaml - # with: - # wheel: dist/otdf_python-0.2.11-py3-none-any.whl diff --git a/.github/workflows/build-golang-ubuntu-buf.yaml b/.github/workflows/build-golang-ubuntu-buf.yaml new file mode 100644 index 0000000..e885d67 --- /dev/null +++ b/.github/workflows/build-golang-ubuntu-buf.yaml @@ -0,0 +1,55 @@ +--- +name: Ubuntu build - buf edition +on: [push] +jobs: + + build: + runs-on: ubuntu-22.04 + permissions: + contents: write + + strategy: + fail-fast: true + matrix: + go-version: [1.24.x] + python3_version: [ "3.11", "3.12", "3.13" ] + + steps: + - uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: go.sum + + # - name: Set up Python + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python3_version }} + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v6 + with: + version: "latest" + python-version: ${{ matrix.python3_version }} + + # Download a release like https://github.com/bufbuild/buf/releases/download/v1.53.0/buf-Linux-x86_64 + - name: Install buf + run: | + BUF_VERSION="1.53.0" + BUF_URL="https://github.com/bufbuild/buf/releases/download/v1.53.0/buf-Linux-x86_64" + curl -sSL "$BUF_URL" -o /usr/local/bin/buf + chmod +x /usr/local/bin/buf + + - name: Add buf to PATH + run: echo "/usr/local/bin" >> $GITHUB_PATH + + - name: Check buf version + run: buf --version + + - name: Build using 'uv_buf_build_script.sh' + run: | + cd buf-build/ + chmod +x ./uv_buf_build_script.sh + ./uv_buf_build_script.sh diff --git a/.github/workflows/build-golang-ubuntu.yaml b/.github/workflows/build-golang-ubuntu.yaml deleted file mode 100644 index 2bbb44b..0000000 --- a/.github/workflows/build-golang-ubuntu.yaml +++ /dev/null @@ -1,65 +0,0 @@ ---- -name: Ubuntu build - -on: [push] - -jobs: - call-lint: - uses: ./.github/workflows/lint-on-ubuntu.yaml - - build: - runs-on: ubuntu-22.04 - permissions: - contents: write - - strategy: - fail-fast: true - matrix: - go-version: [1.22.x] - python3_version: [ "3.11", "3.12" ] - - steps: - - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - cache-dependency-path: go.sum - - name: Install dependencies - run: go get . - - name: Test with Go - run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python3_version }} - - # FIXME: Add more caching - - name: Configure gopy / dependencies, and build wheel - run: | - ./build-scripts/ci-build.sh - - - uses: actions/cache/restore@v4 - with: - path: dist/otdf_python-0.2.11-py3-none-any.whl - key: ${{ runner.os }}${{ matrix.python3_version }}-data-${{ github.sha }} - - - uses: actions/cache/save@v4 - with: - path: dist/otdf_python-0.2.11-py3-none-any.whl - key: ${{ runner.os }}${{ matrix.python3_version }}-data-${{ github.sha }} - restore-keys: | - ${{ runner.os }}${{ matrix.python3_version }}-data- - - integration-test: - strategy: - fail-fast: true - matrix: - python3_version: [ "3.11", "3.12" ] - needs: build - uses: ./.github/workflows/platform-integration-test.yaml - with: - wheel: dist/otdf_python-0.2.11-py3-none-any.whl - python_version: ${{ matrix.python3_version }} diff --git a/.python-version b/.python-version deleted file mode 100644 index e4fba21..0000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12 diff --git a/build-scripts/buf.gen.python.yaml b/buf-build/buf.gen.python.yaml similarity index 100% rename from build-scripts/buf.gen.python.yaml rename to buf-build/buf.gen.python.yaml diff --git a/buf-build/list_wheel_modules.py b/buf-build/list_wheel_modules.py new file mode 100644 index 0000000..7c04bae --- /dev/null +++ b/buf-build/list_wheel_modules.py @@ -0,0 +1,77 @@ +import zipfile +import sys +import argparse # For better command-line argument handling + + +def list_modules_in_wheel(wheel_path): + """ + Lists all Python modules (.py files) contained within a wheel file. + + Args: + wheel_path (str): The path to the .whl file. + + Returns: + list: A list of strings, where each string is the path to a .py file + within the wheel archive. Returns None if an error occurs. + """ + modules = [] + try: + # Check if the file exists and is a file + # (zipfile might raise different errors depending on the OS for directories) + import os + + if not os.path.isfile(wheel_path): + print( + f"Error: Path '{wheel_path}' does not exist or is not a file.", + file=sys.stderr, + ) + return None + + # Open the wheel file (which is essentially a zip archive) in read mode ('r') + with zipfile.ZipFile(wheel_path, "r") as zf: + # Get a list of all archive members (files and directories) + all_files = zf.namelist() + + # Filter the list to include only files ending with '.py' + modules = [name for name in all_files if name.endswith(".py")] + + return modules + + except zipfile.BadZipFile: + print( + f"Error: '{wheel_path}' is not a valid zip file or wheel file.", + file=sys.stderr, + ) + return None + except FileNotFoundError: + # This might be redundant due to the os.path.isfile check, but good practice + print(f"Error: File not found at '{wheel_path}'", file=sys.stderr) + return None + except Exception as e: + print(f"An unexpected error occurred: {e}", file=sys.stderr) + return None + + +# --- Example Usage (when running the script directly) --- +if __name__ == "__main__": + # Set up command-line argument parsing + parser = argparse.ArgumentParser( + description="List Python modules (.py files) found inside a wheel (.whl) file." + ) + parser.add_argument("wheel_file", help="The path to the .whl file to inspect.") + args = parser.parse_args() + + # Get the list of modules + module_list = list_modules_in_wheel(args.wheel_file) + + # Print the results + if module_list is not None: # Check if the function execution was successful + if module_list: + print(f"Found {len(module_list)} module(s) in '{args.wheel_file}':") + for module_path in module_list: + print(f"- {module_path}") + else: + print(f"No .py modules found in '{args.wheel_file}'.") + sys.exit(0) # Exit with success code + else: + sys.exit(1) # Exit with error code diff --git a/buf-build/setup.py b/buf-build/setup.py new file mode 100644 index 0000000..83bc5a2 --- /dev/null +++ b/buf-build/setup.py @@ -0,0 +1,11 @@ +from setuptools import setup, find_packages + +setup( + name="otdf_python", + version="0.2.11", + author="b-long", + author_email="b-long@users.noreply.github.com", + description="Buf generated SDK for OpenTDF", + packages=find_packages("gen"), + package_dir={"": "gen"}, +) diff --git a/build-scripts/uv_buf_build_script.sh b/buf-build/uv_buf_build_script.sh similarity index 50% rename from build-scripts/uv_buf_build_script.sh rename to buf-build/uv_buf_build_script.sh index 4aa5169..e0b9cc1 100755 --- a/build-scripts/uv_buf_build_script.sh +++ b/buf-build/uv_buf_build_script.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Based on the excellent work of the sift-stack team: +# https://github.com/sift-stack/sift/blob/main/docs/python.md set -x set -eou pipefail @@ -17,13 +19,15 @@ loud_print(){ # Based on: https://stackoverflow.com/a/246128 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -BUILD_ROOT="${SCRIPT_DIR}/buf-build" +BUILD_ROOT="${SCRIPT_DIR}/buf-build-generated" +TEST_ROOT="${SCRIPT_DIR}/buf-build-test" # Cleanup previous builds rm -rf .venv-wheel/ rm -rf .venv/ rm -rf dist/ rm -rf "${BUILD_ROOT}" +rm -rf "${TEST_ROOT}" mkdir -p "${BUILD_ROOT}" || { echo "Unable to create build root directory" ; exit 1; } cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; } @@ -43,12 +47,29 @@ if ! command -v go &> /dev/null; then fi +# Shallow clone the 'https://github.com/opentdf/platform.git' repo +git clone --depth 1 https://github.com/opentdf/platform.git + +cd platform || { echo "Unable to change to platform directory" ; exit 1; } +buf export --output=$BUILD_ROOT/protos --config buf.yaml + +cd $SCRIPT_DIR || { echo "Unable to change to script directory" ; exit 1; } +cp buf.gen.python.yaml $BUILD_ROOT/buf.gen.yaml +cp setup.py $BUILD_ROOT/setup.py + +cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; } +buf generate protos || { echo "buf generate failed" ; exit 1; } + +for dir in $(find gen -type d); do + touch $dir/__init__.py +done + # PY_TYPE="--python-preference=only-system" PY_TYPE="--python-preference=only-managed" loud_print "Creating virtual environment" # Install python deps -uv venv .venv --python 3.12 "$PY_TYPE" +uv venv .venv "$PY_TYPE" if ! [ -d "${BUILD_ROOT}/.venv" ]; then echo "Unable to locate virtual environment directory" @@ -58,9 +79,26 @@ fi loud_print "Activating virtual environment" source "${BUILD_ROOT}/.venv/bin/activate" +uv pip install build protobuf grpcio +python -m build --sdist || { echo "Failed to build source distribution" ; exit 1; } +python -m build --wheel || { echo "Failed to build wheel distribution" ; exit 1; } -# Shallow clone the 'https://github.com/opentdf/platform.git' repo -git clone --depth 1 https://github.com/opentdf/platform.git +echo "Build completed successfully." +echo "Directory contents:" +ls -lart +echo "Dist directory contents:" +ls -lart dist/ -cd platform || { echo "Unable to change to platform directory" ; exit 1; } -buf export --output=$BUILD_ROOT/protos --config buf.yaml + +loud_print "Testing new wheel" + +mkdir -p "${TEST_ROOT}" || { echo "Unable to create test root directory" ; exit 1; } +cd "${TEST_ROOT}" || { echo "Unable to change to test root directory" ; exit 1; } +uv venv .venv-wheel +source "${TEST_ROOT}/.venv-wheel/bin/activate" + +echo "Ensuring wheel can be installed" +uv pip install ${BUILD_ROOT}/dist/*.whl || { echo "Failed to install wheel" ; exit 1; } + +loud_print "Listing all wheel modules" +uvx python ${SCRIPT_DIR}/list_wheel_modules.py ${BUILD_ROOT}/dist/*.whl || { echo "Failed to list wheel modules" ; exit 1; } diff --git a/build-scripts/docker-compose.yml b/build-scripts/docker-compose.yml new file mode 100644 index 0000000..64ef667 --- /dev/null +++ b/build-scripts/docker-compose.yml @@ -0,0 +1,276 @@ +name: opentdf +volumes: + configs: + keys: + caddy_data: +configs: + caddy_config: + content: | + { + log { + level INFO + output stdout + } + } + https://keycloak.opentdf.local:9443 { + tls internal + reverse_proxy keycloak:8888 + } + https://platform.opentdf.local:8443 { + tls internal + reverse_proxy { + to h2c://platform:8080 + transport http { + versions h2c 2 1.1 # Enable gRPC proxying + } + } + + } +services: + caddy: + #image: cgr.dev/chainguard/caddy:latest-dev #@sha256:20e31e59503a775f28e7eb0d724384055236a35c52ff4e5aca6caac8390d61dc + image: caddy:alpine + command: ['caddy','run', '--config', '/etc/caddy/Caddyfile'] + configs: + - source: caddy_config + target: /etc/caddy/Caddyfile + ports: + - '9443:9443' + - '8443:8443' + volumes: + - caddy_data:/data + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "wget -q --server-response --tries=1 http://127.0.0.1:2019/metrics 2>&1 | awk '/^ HTTP/{print $2}' | grep -q '200'"] + interval: 5s + timeout: 5s + retries: 3 + check-certs: + image: cgr.dev/chainguard/bash:latest@sha256:553a2674ec4f7d8a701873c1dcb43138f83e787ac1d17043cba0085ae3bd7038 + volumes: + - type: volume + source: caddy_data + target: /etc/ssl/certs + volume: + subpath: caddy/certificates/local/keycloak.opentdf.local/ + command: + - | + echo "Checking certificates" + ls -alh /etc/ssl/certs + cat /etc/ssl/certs/keycloak.opentdf.local.crt + depends_on: + caddy: + condition: service_healthy + ensure-permissions: + condition: service_completed_successfully + ensure-permissions: + image: alpine + command: + - 'sh' + - '-c' + - | + chmod -R 665 /configs + ls -alh /configs + chmod -R 665 /keys + ls -alh /keys + chmod -R 665 /data + ls -alh /data + volumes: + - configs:/configs + - keys:/keys + - caddy_data:/data + + #================================================================ + +# Start Keycloak + + #---------------------------------------------------------------- + keycloak: + image: cgr.dev/chainguard/keycloak:latest@sha256:7e06ca655329cb8256ee2d226e32d48377a1d0e436de4fb10bdd428ed4848afa # 25.0.1 + restart: unless-stopped + command: ['start-dev'] + environment: + KC_DB: postgres + KC_DB_URL_HOST: keycloak-db + KC_DB_URL_PORT: 5432 + KC_DB_URL_DATABASE: keycloak + KC_DB_USERNAME: postgres + KC_DB_PASSWORD: changeme + KC_HOSTNAME: '' + KC_HOSTNAME_ADMIN: '' + KC_HTTP_ENABLED: 'true' + KC_HTTP_PORT: 8888 + KEYCLOAK_ADMIN: admin + KEYCLOAK_ADMIN_PASSWORD: changeme + KC_FEATURES: 'preview,token-exchange' + KC_HEALTH_ENABLED: 'true' + healthcheck: + test: ['CMD-SHELL', '[ -f /tmp/HealthCheck.java ] || echo "public class HealthCheck { public static void main(String[] args) throws java.lang.Throwable { System.exit(java.net.HttpURLConnection.HTTP_OK == ((java.net.HttpURLConnection)new java.net.URL(args[0]).openConnection()).getResponseCode() ? 0 : 1); } }" > /tmp/HealthCheck.java && java /tmp/HealthCheck.java http://localhost:9000/health/ready'] + interval: 5s + timeout: 10s + retries: 3 + start_period: 5m + depends_on: + keycloak-db: + condition: service_healthy + restart: true + keycloak-db: + image: cgr.dev/chainguard/postgres:latest@sha256:f359eed58238db0c9dc24b791e11b197e997e799eb42455f31099fc1492617e7 + restart: unless-stopped + environment: + POSTGRES_PASSWORD: changeme + POSTGRES_USER: postgres + POSTGRES_DB: keycloak + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 5s + timeout: 5s + retries: 10 + start_period: 2m + download-keycloak-config: + image: cgr.dev/chainguard/curl:latest-dev@sha256:8afd56d4c8692ddfdc0ed2b54da2d1e02c0946433cb318700645f9cd70ccdb3a + volumes: + - configs:/configs + command: ['-o', '/configs/keycloak-config.yaml', 'https://raw.githubusercontent.com/opentdf/platform/main/service/cmd/keycloak_data.yaml'] + depends_on: + ensure-permissions: + condition: service_completed_successfully + #================================================================ + +# Provisioning Keycloak with expected realm, clients, and users + + #---------------------------------------------------------------- + keycloak-provisioning: + image: registry.opentdf.io/platform:nightly + volumes: + - configs:/configs + command: + [ + 'provision', + 'keycloak', + '-e', + 'http://keycloak:8888', + '-f', + '/configs/keycloak-config.yaml', + ] + depends_on: + keycloak: + condition: service_healthy + restart: true + download-keycloak-config: + condition: service_completed_successfully + restart: true + #================================================================ + +# Start the OpenTDF service + + #---------------------------------------------------------------- + download-platform-config: + image: cgr.dev/chainguard/curl:latest-dev@sha256:8afd56d4c8692ddfdc0ed2b54da2d1e02c0946433cb318700645f9cd70ccdb3a + volumes: + - configs:/configs + command: ['-o', '/configs/.opentdf.yaml', 'https://raw.githubusercontent.com/opentdf/platform/main/opentdf-dev.yaml'] + depends_on: + ensure-permissions: + condition: service_completed_successfully + modify-platform-config: + image: cgr.dev/chainguard/bash:latest@sha256:553a2674ec4f7d8a701873c1dcb43138f83e787ac1d17043cba0085ae3bd7038 + volumes: + - configs:/configs + command: + - | + echo "Modifying /configs/.opentdf.yaml" + echo "$( str: - go_path = subprocess.check_output(["go", "env", "GOPATH"]).decode("utf-8").strip() - path_val = f"{os.getenv('PATH')}:{go_path}/bin" - return path_val - - -class CustomBuildExt(build_ext): - def build_extension(self, ext: Extension): - bin_path = _generate_path_with_gopath() - go_env = json.loads( - subprocess.check_output(["go", "env", "-json"]).decode("utf-8").strip() - ) - - destination = ( - os.path.dirname(os.path.abspath(self.get_ext_fullpath(ext.name))) - + f"/{PACKAGE_NAME}" - ) - - subprocess.check_call( - [ - "gopy", - "build", - "-no-make", - "-dynamic-link=True", - "-output", - destination, - "-vm", - PYTHON_BINARY, - *ext.sources, - ], - env={"PATH": bin_path, **go_env, "CGO_LDFLAGS_ALLOW": ".*"}, - ) - - # dirty hack to avoid "from pkg import pkg", remove if needed - with open(f"{destination}/__init__.py", "w") as f: - f.write(f"from .{PACKAGE_PATH} import *") - - -this_directory = Path(__file__).parent -long_description = (this_directory / "README.md").read_text() - -setuptools.setup( - name="otdf_python", - version="0.2.11", - author="b-long", - description="Unofficial OpenTDF SDK for Python.", - long_description_content_type="text/markdown", - long_description=long_description, - url="https://github.com/b-long/opentdf-python-sdk", - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - include_package_data=True, - cmdclass={ - "build_ext": CustomBuildExt, - }, - ext_modules=[ - Extension( - PACKAGE_NAME, - [PACKAGE_PATH], - ) - ], -) From e0198b670c7d2e012d5127af29f3742cae0831e6 Mon Sep 17 00:00:00 2001 From: b-long Date: Fri, 2 May 2025 18:45:45 -0400 Subject: [PATCH 3/4] WIP: buf build --- .github/workflows/build-golang-ubuntu-buf.yaml | 5 +++++ .gitignore | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-golang-ubuntu-buf.yaml b/.github/workflows/build-golang-ubuntu-buf.yaml index e885d67..dcbd30c 100644 --- a/.github/workflows/build-golang-ubuntu-buf.yaml +++ b/.github/workflows/build-golang-ubuntu-buf.yaml @@ -53,3 +53,8 @@ jobs: cd buf-build/ chmod +x ./uv_buf_build_script.sh ./uv_buf_build_script.sh + + - uses: actions/upload-artifact@v4 + with: + name: otdf_python_${{ matrix.python3_version }} + path: buf-build/buf-build-generated/dist/*.whl diff --git a/.gitignore b/.gitignore index 89e08d4..b6507bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ #### Start project specific git exclusions otdf_python/ -build-scripts/buf-build/ +buf-build/buf-build-generated/ #### End project specific git exclusions From 4bfcf7fce1f251351f66474616b10901fb841300 Mon Sep 17 00:00:00 2001 From: b-long Date: Fri, 2 May 2025 18:54:36 -0400 Subject: [PATCH 4/4] WIP: buf build --- .github/workflows/build-golang-macos-buf.yaml | 64 +++++++++++++++++++ .../workflows/build-golang-ubuntu-buf.yaml | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-golang-macos-buf.yaml diff --git a/.github/workflows/build-golang-macos-buf.yaml b/.github/workflows/build-golang-macos-buf.yaml new file mode 100644 index 0000000..1cd1558 --- /dev/null +++ b/.github/workflows/build-golang-macos-buf.yaml @@ -0,0 +1,64 @@ +--- +name: macOS build - buf edition +on: [push] +defaults: + run: + shell: bash + +jobs: + build: + runs-on: macos-13 + + permissions: + contents: write + + strategy: + fail-fast: true + matrix: + go-version: [1.24.x] + python3_version: [ "3.11", "3.12", "3.13" ] + + steps: + - uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: go.sum + + # - name: Set up Python + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python3_version }} + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v6 + with: + version: "latest" + python-version: ${{ matrix.python3_version }} + + # Download a release like https://github.com/bufbuild/buf/releases/download/v1.53.0/buf-Linux-x86_64 + - name: Install buf + run: | + BUF_VERSION="1.53.0" + BUF_URL="https://github.com/bufbuild/buf/releases/download/v1.53.0/buf-Darwin-x86_64" + curl -sSL "$BUF_URL" -o /usr/local/bin/buf + chmod +x /usr/local/bin/buf + + - name: Add buf to PATH + run: echo "/usr/local/bin" >> $GITHUB_PATH + + - name: Check buf version + run: buf --version + + - name: Build using 'uv_buf_build_script.sh' + run: | + cd buf-build/ + chmod +x ./uv_buf_build_script.sh + ./uv_buf_build_script.sh + + - uses: actions/upload-artifact@v4 + with: + name: otdf_python_${{ matrix.python3_version }}_macos + path: buf-build/buf-build-generated/dist/*.whl diff --git a/.github/workflows/build-golang-ubuntu-buf.yaml b/.github/workflows/build-golang-ubuntu-buf.yaml index dcbd30c..dc46578 100644 --- a/.github/workflows/build-golang-ubuntu-buf.yaml +++ b/.github/workflows/build-golang-ubuntu-buf.yaml @@ -56,5 +56,5 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: otdf_python_${{ matrix.python3_version }} + name: otdf_python_${{ matrix.python3_version }}_ubuntu path: buf-build/buf-build-generated/dist/*.whl