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
96 changes: 96 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -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/
96 changes: 96 additions & 0 deletions .github/workflows/stable-release-workflow.yml
Original file line number Diff line number Diff line change
@@ -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/
37 changes: 37 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -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",
)
5 changes: 4 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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",
)

Expand Down
6 changes: 6 additions & 0 deletions _version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Version of Tesseract's python distribution

__version__ = '0.1.1'

if __name__ == '__main__':
print(__version__)
1 change: 0 additions & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ cc_library(
],
)


pybind_library(
name = "tesseract_decoder_pybind",
srcs = [
Expand Down
Loading