diff --git a/.github/actions/bump_version/action.yml b/.github/actions/bump_version/action.yml index 84780e06..e7afe3a3 100644 --- a/.github/actions/bump_version/action.yml +++ b/.github/actions/bump_version/action.yml @@ -1,15 +1,49 @@ name: 'Bump Versions' -description: 'This action bumps versions of Cargo.toml and _version.py file, matching release tag' +description: 'This action bumps versions of Cargo.toml file, matching release tag' runs: using: 'composite' steps: - uses: actions/checkout@v4 + # To fetch all the tags and history + with: + fetch-depth: 0 + + - name: Fetch all tags explicitly + run: git fetch --tags + shell: bash + + - name: Get all tags + run: git tag + shell: bash + + - name: Get latest + run: git describe --tags --abbrev=0 2> /dev/null + shell: bash + + - name: Get the exact Git tag or latest tag + dev + run: | + tag=$(git describe --exact-match --tags 2> /dev/null) + if [ $? -ne 0 ]; then + echo "No exact match tag found." + fi + echo "Tag: $tag" + if [ -n "$tag" ]; then + version="$tag" + else + latest_tag=$(git describe --tags --abbrev=0 2> /dev/null) + if [ -z "$latest_tag" ]; then + latest_tag="0.0.0" + fi + version="${latest_tag}.dev" + fi + echo "Version: $version" + echo "version=$version" >> $GITHUB_ENV + shell: bash - name: Bump Cargo version - # python ./cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}" run: | - python .github/actions/bump_version/cargo_version_bumper.py --target Cargo.toml "0.0.1" + python .github/actions/bump_version/cargo_version_bumper.py --target Cargo.toml "${{ env.version }}" shell: bash # - name: Check Cargo.toml version matches Release tag diff --git a/Makefile b/Makefile index 53b6cd87..f32bb81a 100644 --- a/Makefile +++ b/Makefile @@ -30,11 +30,11 @@ install-release: # Build only the Rust Python extension (in debug mode) build-extension-debug: - maturin build + maturin develop # Build only the Rust Python extension (in release mode) build-extension-release: - maturin build --release + maturin develop --release # Watches changes in the rust bindings and updates the python extension in place. watch-extension: diff --git a/python/outlines_core/__init__.py b/python/outlines_core/__init__.py deleted file mode 100644 index 4e8a6375..00000000 --- a/python/outlines_core/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -"""This package provides core functionality for structured generation, formerly implemented in Outlines.""" - -from importlib.metadata import PackageNotFoundError, version - -from .outlines_core import Guide, Index, Vocabulary - -try: - __version__ = version("outlines_core") -except PackageNotFoundError: - pass diff --git a/python/outlines_core/outlines_core.pyi b/python/outlines_core/__init__.pyi similarity index 97% rename from python/outlines_core/outlines_core.pyi rename to python/outlines_core/__init__.pyi index eb578b14..5ed93e84 100644 --- a/python/outlines_core/outlines_core.pyi +++ b/python/outlines_core/__init__.pyi @@ -1,3 +1,5 @@ +"""This package provides core functionality for structured generation, formerly implemented in Outlines.""" + from typing import Dict, List, Optional, Set, Tuple, Union def build_regex_from_schema( diff --git a/python/outlines_core/json_schema.py b/python/outlines_core/json_schema.py deleted file mode 100644 index bfe53b43..00000000 --- a/python/outlines_core/json_schema.py +++ /dev/null @@ -1,16 +0,0 @@ -from .outlines_core import ( # noqa: F401 - BOOLEAN, - DATE, - DATE_TIME, - EMAIL, - INTEGER, - NULL, - NUMBER, - STRING, - STRING_INNER, - TIME, - URI, - UUID, - WHITESPACE, - build_regex_from_schema, -) diff --git a/src/python_bindings/mod.rs b/src/python_bindings/mod.rs index 64148cb2..ec01a6b7 100644 --- a/src/python_bindings/mod.rs +++ b/src/python_bindings/mod.rs @@ -365,6 +365,9 @@ fn register_child_module(parent_module: &Bound<'_, PyModule>) -> PyResult<()> { #[pymodule] fn outlines_core(m: &Bound<'_, PyModule>) -> PyResult<()> { + let version = env!("CARGO_PKG_VERSION"); + m.add("__version__", version)?; + m.add_class::()?; m.add_class::()?; m.add_class::()?;