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
68 changes: 25 additions & 43 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ jobs:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}

# ------------------------------------------------------
# Set Python command (python on Windows, python3 elsewhere)
# ------------------------------------------------------
- name: Set Python command
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "PY=python" >> $GITHUB_ENV
else
echo "PY=python3" >> $GITHUB_ENV
fi

# ------------------------------------------------------
# Windows compiler environment
# ------------------------------------------------------
Expand Down Expand Up @@ -60,52 +72,29 @@ jobs:
echo "CMAKE_CXX_COMPILER=clang++" >> $GITHUB_ENV

# ------------------------------------------------------
# Install cibuildwheel
# Setup Python (non-Windows only)
# Windows uses system Python; cibuildwheel downloads exact versions via nuget
# ------------------------------------------------------
- uses: actions/setup-python@v5
if: runner.os != 'Windows'
with:
python-version: ${{ matrix.python-version }}

- name: Install cibuildwheel
run: pip install cibuildwheel==3.3.0

# ------------------------------------------------------
# Build wheels
# Build and test wheels
# Test config is in pyproject.toml [tool.cibuildwheel]
# ------------------------------------------------------
- name: Build wheels
- name: Install cibuildwheel
run: ${{ env.PY }} -m pip install cibuildwheel==3.3.0

- name: Build and test wheels
shell: bash
run: |
# Dynamically create the build identifier from the matrix
# "3.11" -> "311", "3.12" -> "312"
# Result: CIBW_BUILD="cp311-*"
VER_NO_DOT=$(echo "${{ matrix.python-version }}" | tr -d '.')
export CIBW_BUILD="cp${VER_NO_DOT}-*"

echo "Building for target: $CIBW_BUILD"

# Run cibuildwheel (Platform is auto-detected by cibw)
cibuildwheel --output-dir wheelhouse

# ------------------------------------------------------
# Test built wheel
# ------------------------------------------------------
- name: Test wheel
shell: bash
run: |
# Create fresh venv for testing
python -m venv test-venv
if [[ "$RUNNER_OS" == "Windows" ]]; then
source test-venv/Scripts/activate
else
source test-venv/bin/activate
fi

# Install wheel and test dependencies
pip install wheelhouse/trueform-*.whl
pip install pytest numpy

# Run tests
python -m pytest python/tests -v --tb=short
echo "Building for target: $CIBW_BUILD"
$PY -m cibuildwheel --output-dir wheelhouse

# ------------------------------------------------------
# Package Blender plugin (Python 3.11 / Blender 5.0)
Expand All @@ -114,9 +103,9 @@ jobs:
if: matrix.python-version == env.BLENDER_PYTHON_VERSION
shell: bash
run: |
python -m pip install --force-reinstall wheelhouse/trueform-*.whl
$PY -m pip install --force-reinstall wheelhouse/trueform-*.whl
BLENDER_PY_NO_DOT=$(echo "${{ env.BLENDER_PYTHON_VERSION }}" | tr -d '.')
python python/tools/package_blender_plugin.py \
$PY python/tools/package_blender_plugin.py \
--plugin-init python/examples/bpy-plugin/__init__.py \
--output wheelhouse/trueform-bpy-plugin-${{ runner.os }}-py${BLENDER_PY_NO_DOT}.zip

Expand All @@ -126,7 +115,6 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
# Must include python version in name to prevent overwrites in parallel matrix jobs
name: trueform-wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: |
wheelhouse/*.whl
Expand Down Expand Up @@ -156,9 +144,3 @@ jobs:
dist/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to PyPI

on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v1.2.3)'
required: true
type: string

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download wheels from GitHub Release
run: |
mkdir -p dist
gh release download ${{ github.event.inputs.tag }} --pattern '*.whl' --dir dist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ regex = 'project\(trueform\s+VERSION\s+(?P<value>[0-9.]+)'
# CIBW_BUILD="cp311-* cp312-*"
build = "cp311-*"

# Skip PyPy and unneeded older CPython releases
skip = "pp*"
skip = "*musllinux*"

build-verbosity = 1

# Test wheels after building
test-requires = ["pytest", "pytest-xdist", "numpy"]
test-command = "pytest {project}/python/tests -v --tb=short -n auto"

# Global env variables for all platforms
environment = """
CMAKE_BUILD_PARALLEL_LEVEL=8
CMAKE_BUILD_PARALLEL_LEVEL=12
"""

# -----------------------------------------
Expand Down