Skip to content

Commit a488081

Browse files
stephentoubCopilot
andauthored
fix(python): derive __version__ from package metadata; align Node version sentinel (#1521)
* fix(python): derive __version__ from package metadata with dev sentinel 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> * chore(nodejs): use 0.0.0-dev version sentinel for consistency 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d2df4c commit a488081

6 files changed

Lines changed: 20 additions & 8 deletions

File tree

nodejs/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "git",
55
"url": "https://github.com/github/copilot-sdk.git"
66
},
7-
"version": "0.1.8",
7+
"version": "0.0.0-dev",
88
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
99
"main": "./dist/cjs/index.js",
1010
"types": "./dist/index.d.ts",
@@ -44,7 +44,7 @@
4444
"generate": "cd ../scripts/codegen && npm run generate",
4545
"update:protocol-version": "tsx scripts/update-protocol-version.ts",
4646
"prepublishOnly": "npm run build",
47-
"package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.1.0 --no-git-tag-version --allow-same-version"
47+
"package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.0.0-dev --no-git-tag-version --allow-same-version"
4848
},
4949
"keywords": [
5050
"github",

nodejs/samples/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/scripts/set-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { readFileSync, writeFileSync } from "fs";
33
import { dirname, join } from "path";
44
import { fileURLToPath } from "url";
55

6-
const version = process.env.VERSION || "0.1.0-dev";
6+
const version = process.env.VERSION || "0.0.0-dev";
77
const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
88

99
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));

python/copilot/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
JSON-RPC based SDK for programmatic control of GitHub Copilot CLI
55
"""
66

7+
from importlib.metadata import PackageNotFoundError
8+
from importlib.metadata import version as _pkg_version
9+
710
from ._mode import (
811
BUILTIN_TOOLS_ISOLATED,
912
CopilotClientMode,
@@ -145,7 +148,13 @@
145148
define_tool,
146149
)
147150

148-
__version__ = "0.1.0"
151+
try:
152+
__version__ = _pkg_version("github-copilot-sdk")
153+
except PackageNotFoundError:
154+
# No installed package metadata (e.g. running from a source checkout that
155+
# was never installed). Use a sentinel that can never masquerade as a real
156+
# release rather than a hardcoded version that would silently go stale.
157+
__version__ = "0.0.0.dev0"
149158

150159
__all__ = [
151160
"AutoModeSwitchHandler",

python/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "github-copilot-sdk"
7-
version = "0.1.0"
7+
# Placeholder; the real version is injected at publish time (see
8+
# .github/workflows/publish.yml). Kept as a dev sentinel so source/editable
9+
# installs never report a stale real version, matching the .NET and Rust SDKs.
10+
version = "0.0.0.dev0"
811
description = "Python SDK for GitHub Copilot CLI"
912
readme = "README.md"
1013
requires-python = ">=3.11"

0 commit comments

Comments
 (0)