Skip to content

fix: derive __version__ from package metadata to prevent drift - #30

Merged
edenreich merged 2 commits into
mainfrom
fix/issue-25-20260606-1228
Jun 6, 2026
Merged

edenreich merged 2 commits into
mainfrom
fix/issue-25-20260606-1228

Conversation

@claude

@claude claude Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

inference_gateway.__version__ was hardcoded to 0.5.0 while pyproject.toml declared 0.6.3. Root cause: semantic-release (.releaserc.yaml) only rewrites and commits pyproject.toml on release — it never updates __init__.py, so the literal drifts every release.

This change derives __version__ from installed package metadata via importlib.metadata.version("inference-gateway"), making pyproject.toml the single source of truth and eliminating the drift permanently. A PackageNotFoundError fallback handles running from an uninstalled source checkout.

Added tests/test_version.py to lock __version__ to package metadata and guard against future regressions.

Closes #25

@edenreich

Copy link
Copy Markdown
Contributor

@claude CI is failing.

@claude

claude Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 4m 50s —— View job


CI Failure Investigation

  • Gather context: check CI status and failure logs
  • Identify root cause of the failure
  • Implement the fix
  • Verify locally (lint + tests)
  • Commit the fix

Root cause: tests/test_version.py called version("inference-gateway") directly, but CI never installs the package — it only runs pip install -r requirements.txt + black/pytest (.github/workflows/ci.yml). With no installed distribution, importlib.metadata raised:

importlib.metadata.PackageNotFoundError: No package metadata was found for inference-gateway

Fix: inference_gateway/__init__.py already falls back to "0.0.0" when metadata is absent. The test now mirrors that exact contract — expecting the metadata version when the package is installed and "0.0.0" when it isn't — so it passes in both environments while still failing loudly if a stale hardcoded literal is ever reintroduced.

Note: editing the CI workflow to add pip install -e . would also fix this, but I can't modify .github/workflows/ (GitHub App permissions block workflow edits). The test-side fix is also the more robust choice since it keeps the regression guard meaningful even in an uninstalled checkout.

Verification (replicating CI's uninstalled env against the source tree):

  • pytest tests/ → 23 passed, including test_version_matches_package_metadata
  • black --check . → 15 files unchanged
  • Also confirmed passing in the installed scenario — __version__ matches metadata 0.6.3

Committed as 45a0138 to fix/issue-25-20260606-1228. CI will re-run automatically.
· Branch

@edenreich
edenreich merged commit c150560 into main Jun 6, 2026
@edenreich
edenreich deleted the fix/issue-25-20260606-1228 branch June 6, 2026 12:48
github-actions Bot pushed a commit that referenced this pull request Jun 6, 2026
## [0.7.0](v0.6.3...v0.7.0) (2026-06-06)

### ✨ Features

* add reasoning_format as explicit parameter to create_chat_completion methods ([#34](#34)) ([c2ea888](c2ea888))

### 🐛 Bug Fixes

* correct docker run -e syntax in examples/README.md ([#33](#33)) ([9c756d9](9c756d9)), closes [#27](#27)
* derive __version__ from package metadata to prevent drift ([#30](#30)) ([c150560](c150560))
* make streaming delta content optional ([#31](#31)) ([1c6c533](1c6c533))

### 👷 CI

* centralize claude.yml via reusable workflow ([#13](#13)) ([d0df597](d0df597))
* centralize claude.yml via reusable workflow ([#14](#14)) ([f50da35](f50da35))
* centralize infer.yml + bump infer CLI and sync .infer config ([#17](#17)) ([126c41f](126c41f))
* centralize infer.yml + sync .infer config ([#16](#16)) ([b1166ff](b1166ff))
* centralize infer.yml via reusable workflow ([#15](#15)) ([4c9a38d](4c9a38d))
* **infer:** centralize infer.yml + bump infer CLI and sync .infer config ([#18](#18)) ([7ae73a6](7ae73a6))

### 🔧 Miscellaneous

* **deps:** bump claude-code 2.1.148 -> 2.1.158 ([#20](#20)) ([eeb796b](eeb796b))
* **deps:** bump codex 0.133.0 -> 0.135.0 ([#23](#23)) ([d20f9a2](d20f9a2))
* **deps:** bump infer CLI v0.117.0 -> v0.117.1, infer-action v0.9.1 -> v0.11.1 ([#19](#19)) ([7377902](7377902))
* **deps:** bump infer CLI v0.117.1 -> v0.119.0, infer-action v0.11.2 -> v0.11.4 ([#24](#24)) ([ecc2634](ecc2634))
* **deps:** bump infer-action v0.11.1 -> v0.11.2 ([#22](#22)) ([c348db4](c348db4))
* **flox:** add missing manifest.lock file ([ad15f9f](ad15f9f))
* trim requirements.txt to runtime dependencies only ([#32](#32)) ([0c95d4c](0c95d4c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] __version__ in __init__.py (0.5.0) out of sync with pyproject.toml (0.6.3)

1 participant