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
4 changes: 2 additions & 2 deletions libs/gl-client-py/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pygrpc: ${PROTOSRC}
cd ${PYDIR}; uv run python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/greenlight.proto

check-py:
#uv run --all-packages mypy ${PYDIR}/glclient
uv run --all-packages pytest tests -n $(shell nproc) ${PYDIR}/tests
#uv run --reinstall-package='gl-sdk' --all-packages mypy ${PYDIR}/glclient
uv run --reinstall-package='gl-sdk' --all-packages pytest tests -n $(shell nproc) ${PYDIR}/tests

clean-py:
rm -f ${PYPROTOS} ${PYDIR}/build ${PYDIR}/dist
Expand Down
29 changes: 24 additions & 5 deletions libs/gl-sdk/.tasks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
version: "3"

vars:
LIB_EXT:
sh: |
case "$(uname -s)" in
Darwin*)
echo "dylib"
;;
MINGW*|MSYS*|CYGWIN*)
echo "dll"
;;
*)
echo "so"
;;
esac

tasks:
build:
desc: "Build the gl-sdk library"
Expand All @@ -20,8 +35,9 @@ tasks:
- build-release
cmds:
- |
cp ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} ./libs/gl-sdk/glsdk/libglsdk.{{.LIB_EXT}};
cargo run --bin uniffi-bindgen -- generate \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.so \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} \
--language python \
--out-dir ./libs/gl-sdk/bindings

Expand All @@ -32,8 +48,9 @@ tasks:
- build-release
cmds:
- |
cp ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} ./libs/gl-sdk/glsdk/libglsdk.{{.LIB_EXT}};
cargo run --bin uniffi-bindgen -- generate \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.so \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} \
--language kotlin \
--out-dir ./libs/gl-sdk/bindings

Expand All @@ -44,8 +61,9 @@ tasks:
- build-release
cmds:
- |
cp ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} ./libs/gl-sdk/glsdk/libglsdk.{{.LIB_EXT}};
cargo run --bin uniffi-bindgen -- generate \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.so \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} \
--language swift \
--out-dir ./libs/gl-sdk/bindings

Expand All @@ -56,8 +74,9 @@ tasks:
- build-release
cmds:
- |
cp ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} ./libs/gl-sdk/glsdk/libglsdk.{{.LIB_EXT}};
cargo run --bin uniffi-bindgen -- generate \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.so \
--library ${CARGO_TARGET_DIR:-target}/release/libglsdk.{{.LIB_EXT}} \
--language ruby \
--out-dir ./libs/gl-sdk/bindings

Expand Down Expand Up @@ -106,6 +125,6 @@ tasks:
cmds:
- rm -rf ./bindings
- rm -rf dist/ build/ *.egg-info
- rm -f glsdk/*.so glsdk/glsdk.py
- rm -f glsdk/*.{{.LIB_EXT}} glsdk/glsdk.py
- find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
- find . -type f -name "*.pyc" -delete
23 changes: 23 additions & 0 deletions libs/gl-sdk/hooks/libglsdk_force_include.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
import platform

class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
"""
Sets force-include option for glsdk/libglsdk shared lib.

Does the same as [tool.hatch.build.targets.wheel.force-include], however
assumes system OS and based on that sets the correct extension.
"""
system = platform.system()

match system:
case "Darwin":
lib_ext = ".dylib"
case "Windows":
lib_ext = ".dll"
case _:
lib_ext = ".so"

shared_file = f"glsdk/libglsdk{lib_ext}"
build_data['force_include'][shared_file] = shared_file
4 changes: 2 additions & 2 deletions libs/gl-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ build-backend = "hatchling.build"
packages = ["glsdk"]

# Include the shared library as package data
[tool.hatch.build.targets.wheel.force-include]
"glsdk/libglsdk.so" = "glsdk/libglsdk.so"
[tool.hatch.build.hooks.custom]
path = "hooks/libglsdk_force_include.py"

[dependency-groups]
dev = [
Expand Down
Loading