Skip to content

Use setuptools_scm for dynamic versioning via Git tags #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6bdd92f
Update pyproject.toml
AnnaRevutsky Apr 28, 2025
bc16298
Update __init__.py
AnnaRevutsky Apr 28, 2025
39d6ae7
Update ci.yml
AnnaRevutsky Apr 28, 2025
0a0468c
Update release.yml
AnnaRevutsky Apr 28, 2025
e91e5a6
Update ci.yml
AnnaRevutsky Apr 28, 2025
9d00f8c
Update release.yml
AnnaRevutsky Apr 28, 2025
5999b89
Update release.yml
AnnaRevutsky Apr 28, 2025
49b6e89
Update release.yml
AnnaRevutsky Apr 28, 2025
08c1023
Update release.yml
AnnaRevutsky Apr 28, 2025
07d3e13
Update release.yml
AnnaRevutsky Apr 28, 2025
5892f4c
Update __init__.py and uv.lock for release workflow
AnnaRevutsky Apr 28, 2025
1c253c7
Merge branch 'main' of github.com:AnnaRevutsky/fastapi_mcp
AnnaRevutsky Apr 28, 2025
4e2ebdf
Update pyproject.toml
AnnaRevutsky Apr 29, 2025
42a7b01
Update pyproject.toml
AnnaRevutsky Apr 29, 2025
a371b04
update uv.lock
AnnaRevutsky Apr 29, 2025
7c98b28
Update release.yml
AnnaRevutsky Apr 29, 2025
3dffe77
Update release.yml
AnnaRevutsky Apr 29, 2025
48eef61
Revert "update uv.lock"
AnnaRevutsky Apr 29, 2025
e1b1dd9
Merge branch 'main' of github.com:AnnaRevutsky/fastapi_mcp
AnnaRevutsky Apr 29, 2025
e787e6a
Revert "Update release.yml"
AnnaRevutsky Apr 29, 2025
4429275
Revert uv.lock changes from earlier commit
AnnaRevutsky Apr 29, 2025
24e4d08
Update release.yml
AnnaRevutsky Apr 29, 2025
098dab9
Update release.yml
AnnaRevutsky Apr 29, 2025
6b16762
Update release.yml
AnnaRevutsky May 1, 2025
2245e6d
Update release.yml
AnnaRevutsky May 1, 2025
f8fab0a
Add some amazing feature
AnnaRevutsky May 1, 2025
f232a75
Update release.yml
AnnaRevutsky May 1, 2025
9075a16
Update pyproject.toml
AnnaRevutsky May 1, 2025
70c3a98
Add some package
AnnaRevutsky May 1, 2025
cb98c87
Update release.yml
AnnaRevutsky May 1, 2025
0cb9c51
Update release.yml
AnnaRevutsky May 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main]
pull_request:
branches: [main]

jobs:
ruff:
name: Ruff
Expand Down Expand Up @@ -85,3 +85,5 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false


24 changes: 20 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Release

on:
release:
types: [created]
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
deploy:
Expand All @@ -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/*


15 changes: 8 additions & 7 deletions fastapi_mcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 16 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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",
]

Expand All @@ -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
Expand All @@ -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"

10 changes: 9 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.