From caf3bcf144a7ed1d15d683b7f75c96191d927c30 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Mon, 24 Nov 2025 06:00:36 -0500 Subject: [PATCH 1/2] fix: package ADCP_VERSION file correctly for PyPI distribution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, get_adcp_version() returned "v1" (fallback) when installed from PyPI because ADCP_VERSION was packaged in the wrong location (adcp-2.12.0.data/data/) and couldn't be found at runtime. Changes: - Move ADCP_VERSION into src/adcp/ package directory - Update pyproject.toml to include it as package data - Update get_adcp_version() to read from package location - Remove "v1" fallback to fail fast if file is missing Now returns "2.5.0" correctly when installed from PyPI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- pyproject.toml | 9 +-------- ADCP_VERSION => src/adcp/ADCP_VERSION | 0 src/adcp/__init__.py | 13 +++++++------ 3 files changed, 8 insertions(+), 14 deletions(-) rename ADCP_VERSION => src/adcp/ADCP_VERSION (100%) diff --git a/pyproject.toml b/pyproject.toml index bcebe32..62bfe3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,14 +61,7 @@ Issues = "https://github.com/adcontextprotocol/adcp-client-python/issues" where = ["src"] [tool.setuptools.package-data] -adcp = ["py.typed"] - -# Include ADCP_VERSION file in package -[tool.setuptools] -include-package-data = true - -[tool.setuptools.data-files] -"." = ["ADCP_VERSION"] +adcp = ["py.typed", "ADCP_VERSION"] [tool.black] line-length = 100 diff --git a/ADCP_VERSION b/src/adcp/ADCP_VERSION similarity index 100% rename from ADCP_VERSION rename to src/adcp/ADCP_VERSION diff --git a/src/adcp/__init__.py b/src/adcp/__init__.py index d1443ac..87c9ec6 100644 --- a/src/adcp/__init__.py +++ b/src/adcp/__init__.py @@ -191,15 +191,16 @@ def get_adcp_version() -> str: of the AdCP specification. Returns: - AdCP specification version (e.g., "v1", "v2") + AdCP specification version (e.g., "2.5.0") + + Raises: + FileNotFoundError: If ADCP_VERSION file is missing from package """ from pathlib import Path - # Read from ADCP_VERSION file at project root - version_file = Path(__file__).parent.parent.parent / "ADCP_VERSION" - if version_file.exists(): - return version_file.read_text().strip() - return "v1" # Fallback + # Read from ADCP_VERSION file in package directory + version_file = Path(__file__).parent / "ADCP_VERSION" + return version_file.read_text().strip() __all__ = [ # Version functions From 891bd7f91f3936a97f34fdea34415eced515ae25 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Mon, 24 Nov 2025 06:03:14 -0500 Subject: [PATCH 2/2] refactor: use importlib.resources for ADCP_VERSION file access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch from Path(__file__) to importlib.resources.files() for more robust package data access across different installation methods (editable installs, zip imports, etc.). This is the modern, recommended way to access package data files in Python 3.9+. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/adcp/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adcp/__init__.py b/src/adcp/__init__.py index 87c9ec6..2a18289 100644 --- a/src/adcp/__init__.py +++ b/src/adcp/__init__.py @@ -196,10 +196,10 @@ def get_adcp_version() -> str: Raises: FileNotFoundError: If ADCP_VERSION file is missing from package """ - from pathlib import Path + from importlib.resources import files - # Read from ADCP_VERSION file in package directory - version_file = Path(__file__).parent / "ADCP_VERSION" + # Read from ADCP_VERSION file in package + version_file = files("adcp") / "ADCP_VERSION" return version_file.read_text().strip() __all__ = [