Skip to content

Commit

Permalink
Start development of v1.0 (#2)
Browse files Browse the repository at this point in the history
- Add automated dev version upload to pypi
- Get the merge queue ci working
- Pass version info into the pybind module via compiler flags
- Rerun the getting started notebook with an actual pip install
  • Loading branch information
Strilanc authored Dec 14, 2023
1 parent bb976be commit a7fb414
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 25 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ on:
- main
tags:
- v*
merge_group:
branches:
- main
pull_request:
branches:
- main
Expand Down Expand Up @@ -175,3 +178,17 @@ jobs:
- run: pip install pytest stim sinter pygltflib
- run: pytest src
- run: tools/doctest_proper.py --module chromobius
upload_dev_release_to_pypi:
needs: ["build_dist"]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
packages_dir: dist/
password: ${{ secrets.pypi_token_chromobius }}
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ cc_binary(
"-std=c++20",
"-fvisibility=hidden",
"-DNDEBUG",
"-DVERSION_INFO=0.0.dev0",
],
includes = ["src/"],
linkshared = 1,
Expand Down
1 change: 1 addition & 0 deletions doc/chromobius.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if TYPE_CHECKING:
import stim
import sinter
import chromobius
__version__: str
class CompiledDecoder:
"""A chromobius decoder ready to predict observable flips from detection events.
Expand Down
62 changes: 39 additions & 23 deletions doc/getting_started.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def build_extension(self, ext):
ext.sourcedir,
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={pathlib.Path(self.get_ext_fullpath(ext.name)).parent.absolute()}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DVERSION_INFO={__version__}",
*osx_cmake_flags,
*[
env_arg_item
Expand All @@ -70,7 +71,7 @@ def build_extension(self, ext):
], cwd=build_temp, env=build_env)


__version__ = '0.0.dev0'
__version__ = '1.0.dev0'

with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
Expand Down
5 changes: 4 additions & 1 deletion src/chromobius/pybind/chromobius.pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#include "stim.h"

#define str_literal(s) #s
#define xstr_literal(s) str_literal(s)

struct CompiledDecoder {
chromobius::Decoder decoder;
uint64_t num_detectors;
Expand Down Expand Up @@ -119,7 +122,7 @@ struct CompiledDecoder {
};

PYBIND11_MODULE(chromobius, m) {
m.attr("__version__") = "0.0.dev0";
m.attr("__version__") = xstr_literal(VERSION_INFO);
m.doc() = R"pbdoc(
chromobius: A fast implementation of the mobius color code decoder.
)pbdoc";
Expand Down
4 changes: 4 additions & 0 deletions src/chromobius/pybind/chromobius_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import chromobius


def test_version():
assert chromobius.__version__ is not None


def test_errors():
with pytest.raises(ValueError, match='must be a stim.DetectorErrorModel'):
chromobius.compile_decoder_for_dem(object())
Expand Down
1 change: 1 addition & 0 deletions tools/gen_chromobius_stub_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def main():
import stim
import sinter
import chromobius
__version__: str
'''.strip())

for obj in generate_documentation(obj=chromobius, full_name="chromobius", level=-1):
Expand Down

0 comments on commit a7fb414

Please sign in to comment.