Skip to content

Commit f3dbd41

Browse files
authored
Update build tools to use hatchling and fix reflex build (deployment) (#20)
* fix: Manual version bumping with working .pyi generation - Add build-component task that generates .pyi files selectively - Run pyi_generator from custom_components/ to avoid scanning tests/demo - Fix typecheck by excluding auto-generated .pyi files and build dirs - Fix type error in ClerkProvider.create() using typing.Self - Update bump tasks to echo manual version update instructions * chore: Bump version to 1.2.1 * feat: Switch to hatchling with automatic version bumping - Use hatchling build backend for automatic version management - Configure hatchling to include .pyi artifacts in wheel - Restore task bump-patch/minor/major with hatch version commands - Bump version to 1.2.2 for testing Build verified: 7 .pyi files included, typecheck passes
1 parent f9eb678 commit f3dbd41

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

Taskfile.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ tasks:
3636
- uv run pyright
3737

3838
bump-patch:
39+
desc: Bump patch version (e.g., 1.1.3 -> 1.1.4)
3940
cmds:
4041
- uvx hatch version patch
4142
- uv lock
4243

4344
bump-minor:
45+
desc: Bump minor version (e.g., 1.1.3 -> 1.2.0)
4446
cmds:
4547
- uvx hatch version minor
4648
- uv lock
4749

4850
bump-major:
51+
desc: Bump major version (e.g., 1.1.3 -> 2.0.0)
4952
cmds:
5053
- uvx hatch version major
5154
- uv lock
@@ -68,15 +71,24 @@ tasks:
6871
cmds:
6972
- uv run pre-commit autoupdate
7073

74+
build-component:
75+
desc: Build the reflex component (generates .pyi stubs and package dist)
76+
cmds:
77+
# Generate .pyi files from custom_components to avoid scanning tests/demo dirs
78+
# This is the same as what `reflex component build` does, but selective to avoid
79+
# scanning tests/demo directories which causes ModuleNotFoundError (issue #5114)
80+
- cd custom_components && uv run python -m reflex.utils.pyi_generator reflex_clerk_api
81+
# Build package from root (same as `python -m build .` in reflex component build)
82+
- uv run python -m build .
83+
7184
manual-publish:
7285
preconditions:
7386
# Check environment variable
7487
- sh: test -n "$PYPI_TOKEN"
7588
msg: "PYPI_TOKEN is not set -- Add PYPI_TOKEN=... to .env file"
7689
cmds:
7790
- echo "Publishing to PyPI"
78-
# - uv run reflex component build # Until https://github.com/reflex-dev/reflex/issues/5114 is resolved
79-
- uvx reflex==0.7.5 component build
91+
- task: build-component
8092
- uv publish --token $PYPI_TOKEN
8193

8294
manual-publish-docs:

custom_components/reflex_clerk_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.2.0"
1+
__version__ = "1.2.2"
22

33
from .authentication_components import sign_in, sign_up
44
from .clerk_provider import (

custom_components/reflex_clerk_api/clerk_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55
import uuid
66
from collections.abc import Callable
7-
from typing import Any, ClassVar, TypeVar
7+
from typing import Any, ClassVar, Self, TypeVar, cast
88

99
import authlib.jose.errors as jose_errors
1010
import clerk_backend_api
@@ -535,8 +535,8 @@ class ClerkProvider(ClerkBase):
535535
"""The full URL or path to the waitlist page."""
536536

537537
@classmethod
538-
def create(cls, *children, **props) -> "ClerkProvider":
539-
return super().create(*children, **props)
538+
def create(cls, *children, **props) -> Self:
539+
return cast(Self, super().create(*children, **props))
540540

541541
def add_custom_code(self) -> list[str]:
542542
return []

pyproject.toml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "hatchling"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project.optional-dependencies]
66
dev = ["build", "twine"]
77

8-
[tool.setuptools.packages.find]
9-
where = ["custom_components"]
8+
[tool.hatch.build.targets.wheel]
9+
packages = ["custom_components/reflex_clerk_api"]
1010

11-
[tool.setuptools.dynamic]
12-
version = { attr = "reflex_clerk_api.__version__" }
11+
[tool.hatch.build]
12+
artifacts = ["*.pyi"]
1313

1414
[tool.hatch.version]
1515
path = "custom_components/reflex_clerk_api/__init__.py"
@@ -51,6 +51,14 @@ homepage = "https://reflex-clerk-api-demo.adventuresoftim.com"
5151
[tool.pyright]
5252
venvPath = "."
5353
venv = ".venv"
54+
exclude = [
55+
"**/*.pyi", # Exclude auto-generated .pyi files (not committed, have generator bugs)
56+
".venv", # Exclude virtual environment
57+
"dist", # Exclude build artifacts
58+
"*.egg-info",
59+
"**/.web", # Exclude Reflex web build directory
60+
"**/node_modules", # Exclude npm dependencies
61+
]
5462

5563
[tool.ruff.lint]
5664
extend-select = ["I", "RUF", "T20"]

0 commit comments

Comments
 (0)