Skip to content

Commit 0da793e

Browse files
committed
Replace python_create_package.sh with uv-based build and publish scripts
Add `python_build_wheel.sh` which generates bindings and builds a platform-specific wheel via `uv build`, and `python_publish_package.sh` which publishes collected wheels via `uv publish`. The intended workflow is to run the build script on each target platform (Linux, macOS), collect the wheels, and then publish them in one go. Co-Authored-By: HAL 9000
1 parent 09e7fa4 commit 0da793e

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

scripts/python_build_wheel.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Build a Python wheel for the current platform.
3+
#
4+
# This script compiles the Rust library, generates Python bindings via UniFFI,
5+
# and builds a platform-specific wheel using uv + hatchling.
6+
#
7+
# Run this on each target platform (Linux, macOS) to collect wheels, then use
8+
# scripts/python_publish_package.sh to publish them.
9+
10+
set -e
11+
12+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
14+
15+
cd "$REPO_ROOT"
16+
17+
# Generate bindings and compile the native library
18+
echo "Generating Python bindings..."
19+
./scripts/uniffi_bindgen_generate_python.sh
20+
21+
# Build the wheel
22+
echo "Building wheel..."
23+
cd bindings/python
24+
uv build --wheel
25+
26+
echo ""
27+
echo "Wheel built successfully:"
28+
ls -1 dist/*.whl
29+
echo ""
30+
echo "Collect wheels from all target platforms into dist/, then run:"
31+
echo " ./scripts/python_publish_package.sh"

scripts/python_create_package.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/python_publish_package.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Publish Python wheels to PyPI (or TestPyPI).
3+
#
4+
# Usage:
5+
# ./scripts/python_publish_package.sh # publish to PyPI
6+
# ./scripts/python_publish_package.sh --index testpypi # publish to TestPyPI
7+
#
8+
# Before running, collect wheels from all target platforms into bindings/python/dist/.
9+
10+
set -e
11+
12+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
14+
DIST_DIR="$REPO_ROOT/bindings/python/dist"
15+
16+
if [ ! -d "$DIST_DIR" ] || [ -z "$(ls -A "$DIST_DIR"/*.whl 2>/dev/null)" ]; then
17+
echo "Error: No wheels found in $DIST_DIR"
18+
echo "Run ./scripts/python_build_wheel.sh on each target platform first."
19+
exit 1
20+
fi
21+
22+
echo "Wheels to publish:"
23+
ls -1 "$DIST_DIR"/*.whl
24+
echo ""
25+
26+
uv publish "$@" "$DIST_DIR"/*.whl

0 commit comments

Comments
 (0)