fix(python): derive __version__ from package metadata; align Node version sentinel#1521
Merged
Conversation
The Python SDK hardcoded __version__ = "0.1.0" in copilot/__init__.py and version = "0.1.0" in pyproject.toml. The publish workflow only rewrites pyproject.toml at release time, so the public runtime __version__ drifted and always reported a stale version regardless of what was published. Derive __version__ from installed package metadata via importlib.metadata, falling back to a 0.0.0.dev0 sentinel (instead of a real-looking version) when no metadata is present. Set the committed pyproject.toml version to the same dev sentinel, matching the .NET and Rust SDKs; CI injects the real version at publish time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Node SDK committed a real-looking version (0.1.8) in package.json and reset to 0.1.0 in the package script, unlike the .NET and Rust SDKs which use a 0.0.0-dev sentinel. CI injects the real version at publish via set-version.js, so the committed value should be an unmistakable dev placeholder rather than a stale real version. Align package.json, the package script, set-version.js default, and the package-lock.json files (including nodejs/samples) to 0.0.0-dev. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Python SDK runtime version reporting by deriving copilot.__version__ from installed package metadata, and aligns committed Node SDK development versions with the repo’s dev-sentinel convention.
Changes:
- Python now uses
importlib.metadata.version("github-copilot-sdk")with a0.0.0.dev0fallback. - Python
pyproject.tomluses a PEP 440 dev sentinel that publish CI can still replace. - Node package metadata and lockfiles now use
0.0.0-devconsistently.
Show a summary per file
| File | Description |
|---|---|
python/pyproject.toml |
Replaces stale hardcoded project version with Python dev sentinel and explanatory comment. |
python/copilot/__init__.py |
Derives __version__ from installed package metadata with source-checkout fallback. |
nodejs/scripts/set-version.js |
Updates default fallback version to Node dev sentinel. |
nodejs/package.json |
Updates committed package version and package script reset target. |
nodejs/package-lock.json |
Synchronizes root package lock version entries. |
nodejs/samples/package-lock.json |
Synchronizes sample lockfile’s parent package version entry. |
Copilot's findings
Files not reviewed (2)
- nodejs/package-lock.json: Language not supported
- nodejs/samples/package-lock.json: Language not supported
- Files reviewed: 4/6 changed files
- Comments generated: 0
Contributor
Cross-SDK Consistency Review ✅This PR makes no changes to public API surface — it only updates version sentinel strings in The PR description already includes a thorough audit of all SDK version strategies:
No cross-SDK consistency concerns. The changes appropriately align Python and Node with the convention already established by the other SDKs.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Python SDK was baking in a stale, hardcoded version number.
python/copilot/__init__.pyhad__version__ = "0.1.0"andpython/pyproject.tomlhadversion = "0.1.0". The publish workflow only rewritespyproject.tomlat release time (sed 's/^version = .*/...'), so the public runtime__version__never got updated and permanently reported a stale value regardless of what was actually published.This PR implements the correct fix and brings the Node SDK in line with the dev-sentinel convention already used by the .NET and Rust SDKs.
Changes
Python (the actual fix)
__version__is now derived from the installed package metadata viaimportlib.metadata.version("github-copilot-sdk"), so it always matches what was installed.0.0.0.dev0dev sentinel rather than a real-looking number that would silently go stale again.pyproject.tomlversion is now the0.0.0.dev0dev sentinel; CI injects the real version at publish time.Node (consistency alignment)
package.jsonversion0.1.8→0.0.0-dev, and thepackagescript's trailingnpm version 0.1.0→0.0.0-dev.scripts/set-version.jsdefault fallback0.1.0-dev→0.0.0-dev.package-lock.json(root +packages[""]) andsamples/package-lock.json(packages[".."]) synced to0.0.0-devto keepnpm cihappy.The publish flow is unchanged — CI still injects the real
VERSIONat publish time; only the committed defaults become unmistakable dev placeholders.Audit of the other SDKs
No changes needed; they were already correct:
<Version>0.0.0-dev</Version>(set viadotnet pack -p:Version=)version = "0.0.0-dev"(set viased)go/v…), no embedded version…-SNAPSHOT, managed by maven-release-pluginOnly Python exposed a runtime
__version__, and only Node committed a real-looking number — both addressed here.Validation
__version__resolves from installed metadata; fallback returns the sentinel.0.0.0.dev0is valid PEP 440;0.0.0-devis valid semver.sed '^version = .*'still matches exactly one line.package.jsonand all lockfiles agree on0.0.0-dev; JSON validated.ruff checkpasses on the modified Python file (stdlib import correctly placed for isort).copilot.__version__and no tests assert on it.Reviewed by two independent code-review passes (GPT-5.5 and Opus 4.7); the one issue surfaced (stale
samples/package-lock.json) is fixed here.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com