Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build-golang-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# FIXME: Add more caching
- name: Configure gopy / dependencies, and build wheel
run: |
./ci-build.sh
./build-scripts/ci-build.sh

# - uses: ./.github/workflows/platform-integration-test.yaml
# with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-golang-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
# FIXME: Add more caching
- name: Configure gopy / dependencies, and build wheel
run: |
./ci-build.sh
./build-scripts/ci-build.sh

- uses: actions/cache/restore@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions ci-build.sh → build-scripts/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

set -eou pipefail

# Based on: https://stackoverflow.com/a/246128
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BUILD_ROOT="${SCRIPT_DIR}/.."
cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; }

printf """

✨✨✨ Configure gopy / dependencies, and build wheel ✨✨✨
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ set -eou pipefail
# Ensure we aren't in a virtual environment
deactivate || { echo "Not currently in a virtual environment" ; }

# Based on: https://stackoverflow.com/a/246128
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BUILD_ROOT="${SCRIPT_DIR}/.."
cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; }

SKIP_TESTS="${1:-NO}"

# Cleanup
Expand Down
81 changes: 81 additions & 0 deletions build-scripts/uv_make_and_validate_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/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}/.."
cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; }

SKIP_TESTS="${1:-NO}"

# Cleanup
rm -rf .venv-wheel/
rm -rf .venv/
rm -rf dist/

# 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"
source "${BUILD_ROOT}/.venv/bin/activate"

loud_print "Installing dependencies"
uv pip install wheel pybindgen

if ! [ -d ".venv" ]; then
echo "Unable to locate virtual environment directory"
exit 1
fi

loud_print "Activating virtual environment"
source "${BUILD_ROOT}/.venv/bin/activate"

loud_print "Installing goimports"
go install golang.org/x/tools/cmd/goimports@latest
loud_print "Installing gopy"
go install github.com/go-python/[email protected]

# For every step below, 'which python' should return '.venv/bin/python'
loud_print "Executing gopy"
PATH="$PATH:$HOME/go/bin" gopy build --output=otdf_python -vm=python3 .

loud_print "Installing setuptools"
uv pip install --upgrade setuptools

# Build the 'dist/' folder (wheel)
loud_print "Running 'setup.py bdist_wheel'"
python setup.py bdist_wheel

deactivate

# Prove that the wheel can be installed
loud_print "Installing wheel"

uv venv .venv-wheel --python 3.12 "$PY_TYPE"
source "${BUILD_ROOT}/.venv-wheel/bin/activate"
pip install pybindgen
pip install dist/otdf_python-0.1.14-py3-none-any.whl

if [[ "$SKIP_TESTS" == "-s" || "$SKIP_TESTS" == "--skip-tests" ]]; then
echo "Build is complete, skipping tests."
else
# Validate functionality
echo "Build is complete, running tests."
python validate_otdf_python.py
fi
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
[tool.poetry]
[project]
name = "otdf-python"
# Should match 'setup.py' version number (used for gopy/pybindgen)
version = "0.1.14"
description = "Unofficial OpenTDF SDK for Python."
authors = ["b-long <[email protected]>"]
authors = [
{name="b-long", email="[email protected]"}
]
readme = "README.md"
requires-python = ">=3.11"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependencies]
wheel = "^0.45.0"
pybindgen = "^0.22.1"

[tool.poetry]
package-mode = false

[tool.poetry.dependencies]
python = ">=3.11,<3.14"
wheel = "^0.45.0"
pybindgen = "^0.22.1"


[tool.poetry.group.dev.dependencies]
pytest = "^8.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
pytest = ">=8.1"
7 changes: 7 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading