refactor: Centralize version management in single source of truth
- Create src/skill_seekers/_version.py as single source of truth - Read version dynamically from pyproject.toml at runtime - Update all __init__.py files to import from _version module - Add tomli dependency for Python <3.11 (built-in tomllib for 3.11+) - Remove hardcoded version duplicates (2.7.2 in 3 files) - Fixes version mismatch: pyproject.toml (2.7.4) vs __init__.py (2.7.2) Benefits: - Single place to update version (pyproject.toml) - No more version mismatches across files - Automatic version consistency - Works across Python 3.10-3.13 Before: - pyproject.toml: 2.7.4 - src/skill_seekers/__init__.py: 2.7.2 - src/skill_seekers/cli/__init__.py: 2.7.2 - src/skill_seekers/mcp/__init__.py: 2.7.2 After: - pyproject.toml: 2.7.4 (single source of truth) - All other files: import from _version.py
This commit is contained in:
@@ -61,6 +61,7 @@ dependencies = [
|
||||
"Pygments>=2.19.2",
|
||||
"pathspec>=0.12.1",
|
||||
"networkx>=3.0",
|
||||
"tomli>=2.0.0; python_version < '3.11'", # TOML parser for version reading
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
@@ -5,18 +5,13 @@ This package provides tools for automatically scraping, organizing, and packagin
|
||||
documentation from various sources into uploadable Claude AI skills.
|
||||
"""
|
||||
|
||||
__version__ = "2.7.2"
|
||||
from skill_seekers._version import __version__
|
||||
|
||||
__author__ = "Yusuf Karaaslan"
|
||||
__license__ = "MIT"
|
||||
|
||||
# Expose main components for easier imports
|
||||
from skill_seekers.cli import __version__ as cli_version
|
||||
from skill_seekers.mcp import __version__ as mcp_version
|
||||
|
||||
__all__ = [
|
||||
"__version__",
|
||||
"__author__",
|
||||
"__license__",
|
||||
"cli_version",
|
||||
"mcp_version",
|
||||
]
|
||||
|
||||
52
src/skill_seekers/_version.py
Normal file
52
src/skill_seekers/_version.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
Single source of truth for skill-seekers version.
|
||||
|
||||
This module dynamically reads the version from pyproject.toml to avoid
|
||||
version mismatches across multiple files.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Use tomllib (built-in) for Python 3.11+, tomli (package) for earlier versions
|
||||
if sys.version_info >= (3, 11):
|
||||
import tomllib
|
||||
else:
|
||||
try:
|
||||
import tomli as tomllib
|
||||
except ImportError:
|
||||
# Fallback if tomli not available
|
||||
tomllib = None
|
||||
|
||||
|
||||
def get_version() -> str:
|
||||
"""
|
||||
Read version from pyproject.toml.
|
||||
|
||||
Returns:
|
||||
Version string (e.g., "2.7.4")
|
||||
"""
|
||||
if tomllib is None:
|
||||
# Fallback if TOML library not available
|
||||
return "2.7.4" # Hardcoded fallback
|
||||
|
||||
try:
|
||||
# Get path to pyproject.toml (3 levels up from this file)
|
||||
repo_root = Path(__file__).parent.parent.parent
|
||||
pyproject_path = repo_root / "pyproject.toml"
|
||||
|
||||
if not pyproject_path.exists():
|
||||
# Fallback for installed package
|
||||
return "2.7.4" # Hardcoded fallback
|
||||
|
||||
with open(pyproject_path, "rb") as f:
|
||||
pyproject_data = tomllib.load(f)
|
||||
|
||||
return pyproject_data["project"]["version"]
|
||||
|
||||
except Exception:
|
||||
# Fallback if anything goes wrong
|
||||
return "2.7.4" # Hardcoded fallback
|
||||
|
||||
|
||||
__version__ = get_version()
|
||||
@@ -28,7 +28,8 @@ except ImportError:
|
||||
open_folder = None
|
||||
read_reference_files = None
|
||||
|
||||
__version__ = "2.7.2"
|
||||
# Import centralized version
|
||||
from skill_seekers._version import __version__
|
||||
|
||||
__all__ = [
|
||||
"LlmsTxtDetector",
|
||||
@@ -36,4 +37,5 @@ __all__ = [
|
||||
"LlmsTxtParser",
|
||||
"open_folder",
|
||||
"read_reference_files",
|
||||
"__version__",
|
||||
]
|
||||
|
||||
@@ -28,6 +28,7 @@ Usage:
|
||||
in ~/.config/claude-code/mcp.json
|
||||
"""
|
||||
|
||||
__version__ = "2.7.2"
|
||||
# Import centralized version
|
||||
from skill_seekers._version import __version__
|
||||
|
||||
__all__ = ["agent_detector"]
|
||||
__all__ = ["agent_detector", "__version__"]
|
||||
|
||||
Reference in New Issue
Block a user