diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01087de..d0e655d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: branches: [main] pull_request: branches: [main] - + jobs: ruff: name: Ruff @@ -85,3 +85,5 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: false + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a4acd3..3066f07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,9 @@ name: Release on: - release: - types: [created] + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: deploy: @@ -23,16 +24,31 @@ jobs: with: python-version-file: ".python-version" + - name: Extract version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + - name: Install build dependencies run: | uv sync --all-extras --dev uv pip install build twine + + - name: Build the package + env: + # Use this environment variable to explicitly set the version + SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.VERSION }} + run: | + uv run python -m build + - name: Check built packages + run: | + uv run twine check dist/* + - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | - uv run python -m build - uv run twine check dist/* uv run twine upload dist/* + + diff --git a/fastapi_mcp/__init__.py b/fastapi_mcp/__init__.py index f748712..b47e626 100644 --- a/fastapi_mcp/__init__.py +++ b/fastapi_mcp/__init__.py @@ -3,19 +3,20 @@ Created by Tadata Inc. (https://github.com/tadata-org) """ - try: - from importlib.metadata import version + from ._version import version as __version__ # type: ignore +except ImportError: + try: + from importlib.metadata import version - __version__ = version("fastapi-mcp") -except Exception: # pragma: no cover - # Fallback for local development - __version__ = "0.0.0.dev0" # pragma: no cover + __version__ = version("fastapi-mcp") + except Exception: # pragma: no cover + # Fallback for local development + __version__ = "0.0.0.dev0" # pragma: no cover from .server import FastApiMCP from .types import AuthConfig, OAuthMetadata - __all__ = [ "FastApiMCP", "AuthConfig", diff --git a/pyproject.toml b/pyproject.toml index 2f49e46..74a9e00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,11 @@ [build-system] -requires = ["hatchling", "tomli"] -build-backend = "hatchling.build" +requires = ["setuptools", "setuptools_scm[toml]", "tomli", "wheel"] +build-backend = "setuptools.build_meta" [project] name = "fastapi-mcp" -version = "0.3.3" +dynamic = ["version"] +#version = "0.3.3" description = "Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration" readme = "README.md" requires-python = ">=3.10" @@ -35,6 +36,7 @@ dependencies = [ "uvicorn>=0.20.0", "httpx>=0.24.0", "requests>=2.25.0", + "inspect-mate>=0.0.2", "tomli>=2.2.1", ] @@ -59,8 +61,11 @@ Documentation = "https://github.com/tadata-org/fastapi_mcp#readme" "Source Code" = "https://github.com/tadata-org/fastapi_mcp" "Changelog" = "https://github.com/tadata-org/fastapi_mcp/blob/main/CHANGELOG.md" -[tool.hatch.build.targets.wheel] -packages = ["fastapi_mcp"] +#[tool.hatch.build.targets.wheel] +#packages = ["fastapi_mcp"] + +[project.scripts] +fastapi-mcp = "fastapi_mcp.cli:app" [tool.ruff] line-length = 120 @@ -70,3 +75,9 @@ target-version = "py312" asyncio_mode = "auto" testpaths = ["tests"] python_files = "test_*.py" + +[tool.setuptools_scm] +# This tells setuptools_scm to get the version automatically from Git tags +version_scheme = "post-release" +local_scheme = "no-local-version" + diff --git a/uv.lock b/uv.lock index 1f9071a..515d01f 100644 --- a/uv.lock +++ b/uv.lock @@ -1,4 +1,5 @@ version = 1 +revision = 1 requires-python = ">=3.10" [[package]] @@ -326,11 +327,11 @@ wheels = [ [[package]] name = "fastapi-mcp" -version = "0.3.3" source = { editable = "." } dependencies = [ { name = "fastapi" }, { name = "httpx" }, + { name = "inspect-mate" }, { name = "mcp" }, { name = "pydantic" }, { name = "pydantic-settings" }, @@ -358,6 +359,7 @@ dev = [ requires-dist = [ { name = "fastapi", specifier = ">=0.100.0" }, { name = "httpx", specifier = ">=0.24.0" }, + { name = "inspect-mate", specifier = ">=0.0.2" }, { name = "mcp", specifier = ">=1.6.0" }, { name = "pydantic", specifier = ">=2.0.0" }, { name = "pydantic-settings", specifier = ">=2.5.2" }, @@ -463,6 +465,12 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 }, ] +[[package]] +name = "inspect-mate" +version = "0.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/3d/0e/75bcfbb04eb18002ac864014b3a88a0615a3b90e3f3aa9cb9067503906bd/inspect_mate-0.0.2.tar.gz", hash = "sha256:a51907976d9624d0eeaf0d2207a67c95d174a2fa3aabfdaee53eeaf91d973bdd", size = 13433 } + [[package]] name = "markdown-it-py" version = "3.0.0"