Skip to content

Commit 97c6ffe

Browse files
authored
fix: type stubs in python packaging (#11)
1 parent 249156d commit 97c6ffe

File tree

6 files changed

+52
-1
lines changed

6 files changed

+52
-1
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ jobs:
3030
python-version: "3.11"
3131
enable-cache: true
3232

33+
- name: Update version in __init__.py
34+
if: ${{ steps.release.outputs.release_created }}
35+
run: |
36+
uv run --python-dep tomli scripts/update_version.py
37+
3338
- name: Build and publish package
3439
if: ${{ steps.release.outputs.release_created }}
3540
env:
3641
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
3742
run: |
38-
uv build --no-sources
43+
uv build
3944
uv publish

py.typed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ build-backend = "hatchling.build"
3232
[tool.hatch.build.targets.wheel]
3333
packages = ["stackone_ai"]
3434

35+
[tool.hatch.build.targets.wheel.force-include]
36+
"stackone_ai/py.typed" = "stackone_ai/py.typed"
37+
38+
[tool.hatch.build.targets.wheel.shared-data]
39+
"py.typed" = "py.typed"
40+
3541
[project.optional-dependencies]
3642
examples = [
3743
"crewai>=0.102.0",

scripts/update_version.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
"""
3+
Script to ensure version consistency between pyproject.toml and __init__.py.
4+
Run this script after release-please updates the version in pyproject.toml.
5+
6+
Dependencies:
7+
- tomli
8+
"""
9+
10+
import re
11+
from pathlib import Path
12+
13+
import tomli
14+
15+
16+
def main() -> None:
17+
"""Update version in __init__.py to match pyproject.toml."""
18+
# Read version from pyproject.toml
19+
pyproject_path = Path("pyproject.toml")
20+
init_path = Path("stackone_ai/__init__.py")
21+
22+
with open(pyproject_path, "rb") as f:
23+
pyproject = tomli.load(f)
24+
version = pyproject["project"]["version"]
25+
26+
# Update version in __init__.py
27+
init_content = init_path.read_text()
28+
new_init_content = re.sub(r'__version__ = "[^"]+"', f'__version__ = "{version}"', init_content)
29+
30+
if init_content != new_init_content:
31+
init_path.write_text(new_init_content)
32+
print(f"Updated version in {init_path} to {version}")
33+
else:
34+
print(f"Version in {init_path} already matches {version}")
35+
36+
37+
if __name__ == "__main__":
38+
main()

stackone_ai/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
from .toolset import StackOneToolSet
44

55
__all__ = ["StackOneToolSet"]
6+
__version__ = "0.0.2"

stackone_ai/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)