Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/build-golang-macos-buf.yaml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 0 additions & 50 deletions .github/workflows/build-golang-macos.yaml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/build-golang-ubuntu-buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
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

- uses: actions/upload-artifact@v4
with:
name: otdf_python_${{ matrix.python3_version }}_ubuntu
path: buf-build/buf-build-generated/dist/*.whl
65 changes: 0 additions & 65 deletions .github/workflows/build-golang-ubuntu.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#### Start project specific git exclusions
otdf_python/
buf-build/buf-build-generated/

#### End project specific git exclusions

Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

10 changes: 10 additions & 0 deletions buf-build/buf.gen.python.yaml
Original file line number Diff line number Diff line change
@@ -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
77 changes: 77 additions & 0 deletions buf-build/list_wheel_modules.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions buf-build/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from setuptools import setup, find_packages

setup(
name="otdf_python",
version="0.2.11",
author="b-long",
author_email="[email protected]",
description="Buf generated SDK for OpenTDF",
packages=find_packages("gen"),
package_dir={"": "gen"},
)
Loading