Publish Python Package to PyPI #98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-License-Identifier: Apache-2.0 | |
| # Copyright (c) 2018-2026 BioInception PVT LTD | |
| name: Publish Python Package to PyPI | |
| on: | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| build: | |
| name: Build wheels — ${{ matrix.os }} ${{ matrix.cibw_archs }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-22.04 | |
| cibw_archs: "x86_64" | |
| # Linux aarch64 (Graviton, Ampere, RPi) | |
| - os: ubuntu-22.04 | |
| cibw_archs: "aarch64" | |
| # macOS arm64 (Apple Silicon) | |
| - os: macos-latest | |
| cibw_archs: "arm64" | |
| # macOS x86_64 (Intel) — cross-compile on arm64 runner | |
| - os: macos-latest | |
| cibw_archs: "x86_64" | |
| # Windows x64 | |
| - os: windows-latest | |
| cibw_archs: "AMD64" | |
| steps: | |
| - uses: actions/checkout@v4.3.1 | |
| # QEMU for Linux aarch64 cross-compilation | |
| - name: Set up QEMU | |
| if: matrix.cibw_archs == 'aarch64' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.22 | |
| with: | |
| package-dir: . | |
| env: | |
| CIBW_ARCHS: ${{ matrix.cibw_archs }} | |
| CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*" | |
| CIBW_SKIP: "*-musllinux_*" | |
| CIBW_BEFORE_BUILD: "pip install pybind11 scikit-build-core cmake ninja" | |
| CIBW_BEFORE_BUILD_LINUX: > | |
| yum install -y libgomp-devel 2>/dev/null || | |
| apt-get update && apt-get install -y libgomp1 libomp-dev 2>/dev/null || | |
| true | |
| CIBW_BUILD_VERBOSITY: "3" | |
| # macOS: let delocate bundle libomp into the wheel | |
| CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "" | |
| # Skip Metal shader test on x86_64 macOS (hangs in headless CI) | |
| CIBW_TEST_SKIP: "*-macosx_x86_64" | |
| CIBW_TEST_COMMAND: > | |
| python -c "import smsd; | |
| print('SMSD', smsd.__version__, 'imported OK'); | |
| m = smsd.parse_smiles('c1ccccc1'); | |
| print('Benzene:', len(m), 'atoms')" | |
| - uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ matrix.cibw_archs }} | |
| path: wheelhouse/*.whl | |
| build-sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4.3.1 | |
| - name: Build sdist | |
| run: | | |
| pip install build | |
| python -m build --sdist | |
| - uses: actions/upload-artifact@v4.6.2 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build, build-sdist] | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4.3.0 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |