diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 0000000..7b9eecc --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,96 @@ +name: Pre-release Tesseract + +on: + push: + branches: + - main + +permissions: + contents: read + +jobs: + create_version: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 + with: + python-version: '3.10' + - name: Create version + run: | + mkdir version + echo "$(python _version.py).dev$(date '+%Y%m%d%H%M%S')" > version/version.txt + cat version/version.txt + - uses: actions/upload-artifact@master + with: + name: version-file + path: version + + build_wheels: + runs-on: ${{ matrix.os }} + needs: [create_version] + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + arch: x86_64 + - os: macos-13 + arch: auto + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Set up Python + uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 + with: + python-version: '3.10' + + - uses: actions/download-artifact@master + with: + name: version-file + path: version + + - name: Set up Bazel + uses: bazel-contrib/setup-bazel@0.14.0 + with: + bazelisk-cache: true + disk-cache: ${{ github.workflow }} + repository-cache: true + + - name: Build package + run: | + bazel build --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel + + - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4 + with: + name: python-wheels-${{ matrix.os }} + path: ./bazel-bin/*.whl + + release-wheels: + name: Publish all wheels + needs: [build_wheels] + runs-on: ubuntu-24.04 + + steps: + - name: Download build artifacts + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 + with: + pattern: python-wheels-* + merge-multiple: true + path: wheelhouse/ + + - name: Publish package to testpypi + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + repository_url: https://test.pypi.org/legacy/ + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + packages_dir: wheelhouse/ + verbose: true + + - name: Publish package to pypi + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + packages_dir: wheelhouse/ diff --git a/.github/workflows/stable-release-workflow.yml b/.github/workflows/stable-release-workflow.yml new file mode 100644 index 0000000..de7c291 --- /dev/null +++ b/.github/workflows/stable-release-workflow.yml @@ -0,0 +1,96 @@ +name: Stable-release Tesseract + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + create_version: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 + with: + python-version: '3.10' + - name: Create version + run: | + mkdir version + echo "$(python _version.py)" > version/version.txt + cat version/version.txt + - uses: actions/upload-artifact@master + with: + name: version-file + path: version + + build_wheels: + runs-on: ${{ matrix.os }} + needs: [create_version] + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + arch: x86_64 + - os: macos-13 + arch: auto + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Set up Python + uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 + with: + python-version: '3.10' + + - uses: actions/download-artifact@master + with: + name: version-file + path: version + + - name: Set up Bazel + uses: bazel-contrib/setup-bazel@0.14.0 + with: + bazelisk-cache: true + disk-cache: ${{ github.workflow }} + repository-cache: true + + - name: Build package + run: | + bazel build --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel + + - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4 + with: + name: python-wheels-${{ matrix.os }} + path: ./bazel-bin/*.whl + + release-wheels: + name: Publish all wheels + needs: [build_wheels] + runs-on: ubuntu-24.04 + + steps: + - name: Download build artifacts + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 + with: + pattern: python-wheels-* + merge-multiple: true + path: wheelhouse/ + + + - name: Publish package to testpypi + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + repository_url: https://test.pypi.org/legacy/ + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + packages_dir: wheelhouse/ + verbose: true + + - name: Publish package to pypi + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + packages_dir: wheelhouse/ diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..1225b3a --- /dev/null +++ b/BUILD @@ -0,0 +1,37 @@ +load("@rules_python//python:packaging.bzl", "py_wheel") + +filegroup( + name="package_description", + srcs=["README.md"], + visibility = ["//visibility:public"], +) + + +filegroup( + name="package_data", + srcs=["LICENSE"], + visibility = ["//visibility:public"], +) + +py_wheel( + name="tesseract_decoder_wheel", + distribution = "tesseract_decoder", + deps=[ + "//src:tesseract_decoder", + ":package_data", + ], + version = "$(VERSION)", + requires=[ + "stim", + ], + platform= select({ + "@platforms//os:macos": "macosx_10_13_x86_64", + "@platforms//os:windows": "win32", + "@platforms//os:linux": "manylinux_2_17_x86_64.manylinux2014_x86_64", + }), + description_file=":package_description", + description_content_type="text/markdown", + summary="A search-based decoder for quantum error correction (QEC).", + author="The Tesseract Decoder Authors.", + homepage="https://github.com/quantumlib/tesseract-decoder", +) diff --git a/MODULE.bazel b/MODULE.bazel index 98f03c8..0404c79 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -8,6 +8,9 @@ bazel_dep(name = "pybind11_bazel", version = "2.13.6") DEFAULT_PYTHON_VERSION = "3.11" +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain(python_version = DEFAULT_PYTHON_VERSION, is_default = True) + python_configure = use_extension("@pybind11_bazel//:python_configure.bzl", "extension") use_repo(python_configure, "local_config_python") @@ -16,7 +19,7 @@ pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( hub_name = "pypi", - python_version = "3.11", + python_version = DEFAULT_PYTHON_VERSION, requirements_lock = "//src/py:requirements_lock.txt", ) diff --git a/_version.py b/_version.py new file mode 100644 index 0000000..646b797 --- /dev/null +++ b/_version.py @@ -0,0 +1,6 @@ +# Version of Tesseract's python distribution + +__version__ = '0.1.1' + +if __name__ == '__main__': + print(__version__) diff --git a/src/BUILD b/src/BUILD index 3dfd129..5596f05 100644 --- a/src/BUILD +++ b/src/BUILD @@ -63,7 +63,6 @@ cc_library( ], ) - pybind_library( name = "tesseract_decoder_pybind", srcs = [