name: "Nightly-Linux-x64" on: workflow_dispatch: inputs: is_nightly: description: 'Whether to build the nightly package (sets DEV_BUILD=1)' required: true default: true type: boolean publish_to_pypi: description: 'Publish to PyPI' required: true default: false type: boolean schedule: - cron: '0 21 * * *' timezone: 'America/Los_Angeles' jobs: build-linux-wheel: name: "Build Python Wheel ${{ matrix.python-version }}" runs-on: ubuntu-22.04-8core env: DEV_BUILD: ${{ (github.event_name == 'schedule' || github.event.inputs.is_nightly == 'true') && '1' || '0' }} PUBLISH_TO_PYPI: ${{ (github.event_name == 'schedule' || github.event.inputs.publish_to_pypi == 'true') && 'true' || 'false' }} strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - name: Checkout code. uses: actions/checkout@v4 with: lfs: true - name: Build Python Wheel # Building with --define=xnn_enable_avxvnniint8=false because the Clang # version on Ubuntu 22.04 does not support -mavxvnniint8. Ubuntu 22.04 # is used to maintain compatibility with Google Colab environments. run: | PYTHON_VERSION=${{ matrix.python-version }} DATE=$(TZ=America/Los_Angeles date +'%Y%m%d') bazel build \ --repo_env=HERMETIC_PYTHON_VERSION=${PYTHON_VERSION} \ --@rules_python//python/config_settings:python_version=${PYTHON_VERSION} \ --define=DEV_BUILD=${{ env.DEV_BUILD }} \ --define=DEV_VERSION=${DATE} \ --define=litert_link_capi_so=true \ --define=resolve_symbols_in_exec=false \ --define=xnn_enable_avxvnniint8=false \ -c opt //python/litert_lm:wheel - name: Install uv uses: astral-sh/setup-uv@v5 - name: Test Python Wheel run: | PYTHON_VERSION=${{ matrix.python-version }} uv venv --python=${PYTHON_VERSION} # Install the built wheel WHEEL_PATH=$(find bazel-bin/python/litert_lm -name "*.whl" | head -n 1) uv pip install $WHEEL_PATH # Run the verification script uv run python python/litert_lm/examples/simple_main.py - name: Publish to PyPI if: env.PUBLISH_TO_PYPI == 'true' env: UV_PUBLISH_TOKEN: ${{ secrets.PYPI_UPLOAD_TOKEN }} run: | WHEEL_PATH=$(find bazel-bin/python/litert_lm -name "*.whl" | head -n 1) uv publish $WHEEL_PATH # We just need to build the CLI once and it can works on all Python # versions and different OSs. We pick Linux 3.13. - name: Build CLI Python Wheel if: matrix.python-version == '3.13' run: | DATE=$(TZ=America/Los_Angeles date +'%Y%m%d') bazel build \ --define=DEV_BUILD=${{ env.DEV_BUILD }} \ --define=DEV_VERSION=${DATE} \ --define=xnn_enable_avxvnniint8=false \ -c opt //python/litert_lm_cli:wheel - name: Test CLI Python Wheel if: matrix.python-version == '3.13' run: | WHEEL_PATH=$(find bazel-bin/python/litert_lm_cli -name "*.whl" | head -n 1) uv pip install $WHEEL_PATH uv run litert-lm --help - name: Publish CLI to PyPI if: matrix.python-version == '3.13' && env.PUBLISH_TO_PYPI == 'true' env: UV_PUBLISH_TOKEN: ${{ secrets.PYPI_UPLOAD_TOKEN }} run: | WHEEL_PATH=$(find bazel-bin/python/litert_lm_cli -name "*.whl" | head -n 1) uv publish $WHEEL_PATH