Skip to content

Commit 161656d

Browse files
bokelleyclaude
andauthored
fix: correct ADCP_VERSION packaging for PyPI (#85)
* fix: package ADCP_VERSION file correctly for PyPI distribution 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 <noreply@anthropic.com> * refactor: use importlib.resources for ADCP_VERSION file access 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 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d3acbf7 commit 161656d

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,7 @@ Issues = "https://github.com/adcontextprotocol/adcp-client-python/issues"
6161
where = ["src"]
6262

6363
[tool.setuptools.package-data]
64-
adcp = ["py.typed"]
65-
66-
# Include ADCP_VERSION file in package
67-
[tool.setuptools]
68-
include-package-data = true
69-
70-
[tool.setuptools.data-files]
71-
"." = ["ADCP_VERSION"]
64+
adcp = ["py.typed", "ADCP_VERSION"]
7265

7366
[tool.black]
7467
line-length = 100
File renamed without changes.

src/adcp/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,16 @@ def get_adcp_version() -> str:
191191
of the AdCP specification.
192192
193193
Returns:
194-
AdCP specification version (e.g., "v1", "v2")
194+
AdCP specification version (e.g., "2.5.0")
195+
196+
Raises:
197+
FileNotFoundError: If ADCP_VERSION file is missing from package
195198
"""
196-
from pathlib import Path
199+
from importlib.resources import files
197200

198-
# Read from ADCP_VERSION file at project root
199-
version_file = Path(__file__).parent.parent.parent / "ADCP_VERSION"
200-
if version_file.exists():
201-
return version_file.read_text().strip()
202-
return "v1" # Fallback
201+
# Read from ADCP_VERSION file in package
202+
version_file = files("adcp") / "ADCP_VERSION"
203+
return version_file.read_text().strip()
203204

204205
__all__ = [
205206
# Version functions

0 commit comments

Comments
 (0)