feat(python): reads version from tag

This commit is contained in:
Marc Nuri
2025-04-07 18:47:54 +02:00
parent 470d1c6327
commit 25200da8f8
3 changed files with 14 additions and 7 deletions

View File

@@ -7,6 +7,13 @@ import shutil
import tempfile
import urllib.request
if sys.version_info >= (3, 8):
from importlib.metadata import version
else:
from importlib_metadata import version
__version__ = version("kubernetes-mcp-server")
def get_platform_binary():
"""Determine the correct binary for the current platform."""
system = platform.system().lower()
@@ -29,11 +36,11 @@ def get_platform_binary():
else:
raise RuntimeError(f"Unsupported operating system: {system}")
def download_binary(version="latest", destination=None):
def download_binary(binary_version="latest", destination=None):
"""Download the correct binary for the current platform."""
binary_name = get_platform_binary()
if destination is None:
destination = Path.home() / ".kubernetes-mcp-server" / "bin"
destination = Path.home() / ".kubernetes-mcp-server" / "bin" / binary_version
destination = Path(destination)
destination.mkdir(parents=True, exist_ok=True)
@@ -43,10 +50,10 @@ def download_binary(version="latest", destination=None):
return binary_path
base_url = "https://github.com/manusa/kubernetes-mcp-server/releases"
if version == "latest":
if binary_version == "latest":
release_url = f"{base_url}/latest/download/{binary_name}"
else:
release_url = f"{base_url}/download/{version}/{binary_name}"
release_url = f"{base_url}/download/v{binary_version}/{binary_name}"
# Download the binary
print(f"Downloading {binary_name} from {release_url}")
@@ -71,7 +78,7 @@ def execute(args=None):
args = []
try:
binary_path = download_binary()
binary_path = download_binary(binary_version=__version__)
cmd = [str(binary_path)] + args
# Execute the binary with the provided arguments

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "kubernetes-mcp-server"
version = "0.0.21-7-g869ebc2"
version = "0.0.0"
description = "Kubernetes MCP Server (Model Context Protocol) with special support for OpenShift"
readme = {file="README.md", content-type="text/markdown"}
requires-python = ">=3.6"

2
python/uv.lock generated
View File

@@ -4,5 +4,5 @@ requires-python = ">=3.6"
[[package]]
name = "kubernetes-mcp-server"
version = "0.0.0.dev3"
version = "0.0.23"
source = { editable = "." }