From 86672d717c9adf12bd3c6ffd5f5619ecb4c622ee Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Wed, 5 Mar 2025 11:45:26 +0000 Subject: [PATCH] fix: type stubs in python packaging --- .github/workflows/release.yml | 7 ++++++- py.typed | 1 + pyproject.toml | 6 ++++++ scripts/update_version.py | 38 +++++++++++++++++++++++++++++++++++ stackone_ai/__init__.py | 1 + stackone_ai/py.typed | 0 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 py.typed create mode 100755 scripts/update_version.py create mode 100644 stackone_ai/py.typed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f465e38..0862706 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,10 +30,15 @@ jobs: python-version: "3.11" enable-cache: true + - name: Update version in __init__.py + if: ${{ steps.release.outputs.release_created }} + run: | + uv run --python-dep tomli scripts/update_version.py + - name: Build and publish package if: ${{ steps.release.outputs.release_created }} env: UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} run: | - uv build --no-sources + uv build uv publish diff --git a/py.typed b/py.typed new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/py.typed @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ae5777f..bb17bea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,12 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["stackone_ai"] +[tool.hatch.build.targets.wheel.force-include] +"stackone_ai/py.typed" = "stackone_ai/py.typed" + +[tool.hatch.build.targets.wheel.shared-data] +"py.typed" = "py.typed" + [project.optional-dependencies] examples = [ "crewai>=0.102.0", diff --git a/scripts/update_version.py b/scripts/update_version.py new file mode 100755 index 0000000..ae2c3f3 --- /dev/null +++ b/scripts/update_version.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +""" +Script to ensure version consistency between pyproject.toml and __init__.py. +Run this script after release-please updates the version in pyproject.toml. + +Dependencies: +- tomli +""" + +import re +from pathlib import Path + +import tomli + + +def main() -> None: + """Update version in __init__.py to match pyproject.toml.""" + # Read version from pyproject.toml + pyproject_path = Path("pyproject.toml") + init_path = Path("stackone_ai/__init__.py") + + with open(pyproject_path, "rb") as f: + pyproject = tomli.load(f) + version = pyproject["project"]["version"] + + # Update version in __init__.py + init_content = init_path.read_text() + new_init_content = re.sub(r'__version__ = "[^"]+"', f'__version__ = "{version}"', init_content) + + if init_content != new_init_content: + init_path.write_text(new_init_content) + print(f"Updated version in {init_path} to {version}") + else: + print(f"Version in {init_path} already matches {version}") + + +if __name__ == "__main__": + main() diff --git a/stackone_ai/__init__.py b/stackone_ai/__init__.py index ea67c0a..94e52f6 100644 --- a/stackone_ai/__init__.py +++ b/stackone_ai/__init__.py @@ -3,3 +3,4 @@ from .toolset import StackOneToolSet __all__ = ["StackOneToolSet"] +__version__ = "0.0.2" diff --git a/stackone_ai/py.typed b/stackone_ai/py.typed new file mode 100644 index 0000000..e69de29