@@ -14,6 +14,22 @@ handle_error() {
1414
1515echo " 🐍 Building Python SDK..."
1616
17+ # Parse command line arguments
18+ BUMP_VERSION=false
19+ while [[ $# -gt 0 ]]; do
20+ case $1 in
21+ --bump-version)
22+ BUMP_VERSION=true
23+ shift
24+ ;;
25+ * )
26+ echo " Unknown option: $1 "
27+ echo " Usage: $0 [--bump-version]"
28+ exit 1
29+ ;;
30+ esac
31+ done
32+
1733# Check if virtual environment exists
1834if [ ! -d " .venv" ]; then
1935 echo " 🔧 Creating Python virtual environment..."
@@ -27,6 +43,36 @@ source .venv/bin/activate
2743echo " 📦 Installing Python dependencies..."
2844pip install -e .[dev] --quiet
2945
46+ # Version bumping logic
47+ if [ " $BUMP_VERSION " = true ]; then
48+ echo " 📝 Bumping version..."
49+ CURRENT_VERSION=$( grep ' ^version = ' pyproject.toml | cut -d' "' -f2)
50+ echo " Current version: $CURRENT_VERSION "
51+
52+ # Split version into parts
53+ IFS=' .' read -r -a VERSION_PARTS <<< " $CURRENT_VERSION"
54+ MAJOR=${VERSION_PARTS[0]}
55+ MINOR=${VERSION_PARTS[1]}
56+ PATCH=${VERSION_PARTS[2]}
57+
58+ # Increment patch version
59+ NEW_PATCH=$(( PATCH + 1 ))
60+ NEW_VERSION=" $MAJOR .$MINOR .$NEW_PATCH "
61+
62+ echo " New version: $NEW_VERSION "
63+
64+ # Update pyproject.toml
65+ if [[ " $OSTYPE " == " darwin" * ]]; then
66+ # macOS
67+ sed -i ' ' " s/^version = \" .*\" /version = \" $NEW_VERSION \" /" pyproject.toml
68+ else
69+ # Linux
70+ sed -i " s/^version = \" .*\" /version = \" $NEW_VERSION \" /" pyproject.toml
71+ fi
72+
73+ echo " ✅ Version updated to $NEW_VERSION "
74+ fi
75+
3076echo " 🧪 Running Python tests..."
3177export PYTHONPATH=" ./python/src:./python/tests"
3278pytest python/tests --quiet
@@ -35,8 +81,27 @@ echo "🚀 Python linting and formatting..."
3581ruff check . --fix --quiet
3682ruff format . --quiet
3783
84+ echo " 📦 Building distribution packages..."
85+ # Clean ALL previous builds (including any in root dist/)
86+ echo " 🧹 Cleaning previous builds..."
87+ rm -rf ./dist ./build ./python/dist ./python/build ./python/src/* .egg-info ./src/* .egg-info * .egg-info
88+
89+ # Build source distribution and wheel
90+ echo " 🔨 Creating distribution packages..."
91+ python -m build --outdir ./python/dist
92+
93+ echo " ✅ Distribution packages created:"
94+ ls -la ./python/dist/
95+
96+ echo
3897echo " ############################################################"
3998echo " # #"
4099echo " # 🎉 Python SDK build complete! 🐍 #"
41100echo " # #"
101+ echo " # Distribution packages ready in ./python/dist/ #"
102+ echo " # #"
103+ echo " # To publish to PyPI: #"
104+ echo " # 1. Bump version: ./dev/build/python.sh --bump-version #"
105+ echo " # 2. Upload: twine upload ./python/dist/* #"
106+ echo " # #"
42107echo " ############################################################"
0 commit comments