Skip to content

Commit 1d5706a

Browse files
python: switch from bundled CLI wheels to download-at-first-use
Replace the platform-specific fat wheel approach (6 × ~90MB wheels per release) with a single slim pure-Python wheel that downloads the CLI binary from GitHub Releases on first use and caches it locally. Key changes: - New _cli_version.py: platform asset mapping, version sentinel (injected at publish time by inject-cli-version.mjs) - New _cli_download.py: download, SHA-256 verify, extract, atomic cache logic - New __main__.py: 'python -m copilot download-cli' pre-download command - Updated client.py resolution chain: explicit > env var > downloaded (removed bundled binary fallback entirely) - Updated publish.yml: single 'uv build --wheel' instead of build-wheels.mjs - Removed build-wheels.mjs (old fat wheel builder) - Updated docs to reflect Python's new download model The cache directory is shared with the Rust SDK: Linux: ~/.cache/github-copilot-sdk/cli/{version}/copilot macOS: ~/Library/Caches/github-copilot-sdk/cli/{version}/copilot Windows: %LOCALAPPDATA%\github-copilot-sdk\cli\{version}\copilot.exe Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d15cfcb commit 1d5706a

13 files changed

Lines changed: 598 additions & 409 deletions

File tree

.github/workflows/publish.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ jobs:
214214
run: npm ci --ignore-scripts
215215
- name: Set version
216216
run: sed -i "s/^version = .*/version = \"${{ needs.version.outputs.version }}\"/" pyproject.toml
217-
- name: Build platform wheels
218-
run: node scripts/build-wheels.mjs --output-dir dist
217+
- name: Inject CLI version
218+
run: node scripts/inject-cli-version.mjs
219+
- name: Build wheel
220+
run: uv build --wheel --out-dir dist
219221
- name: Upload artifact
220222
uses: actions/upload-artifact@v7.0.0
221223
with:

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Copilot: In Tokyo it's 75°F and sunny. Great day to be outside!
1818

1919
Before you begin, make sure you have:
2020

21-
* **GitHub Copilot CLI** installed and authenticated (the Node.js, Python, and .NET SDKs bundle the CLI automatically—see [Bundled CLI](./setup/bundled-cli.md). Required for Go, Java, and Rust unless using their application-level CLI bundling features.)
21+
* **GitHub Copilot CLI** installed and authenticated (the Node.js, Python, and .NET SDKs provide the CLI automatically—see [Bundled CLI](./setup/bundled-cli.md). Required for Go, Java, and Rust unless using their application-level CLI bundling features.)
2222
* Your preferred language runtime:
2323
* **Node.js** 20+ or **Python** 3.11+ or **Go** 1.24+ or **Rust** 1.94+ or **Java** 17+ or **.NET** 8.0+
2424

docs/setup/bundled-cli.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# Default setup (bundled CLI)
22

3-
The Node.js, Python, and .NET SDKs include the Copilot CLI as a dependency—your app ships with everything it needs, with no extra installation or configuration required.
3+
The Node.js and .NET SDKs include the Copilot CLI as a dependency—your app ships with everything it needs, with no extra installation or configuration required.
4+
5+
The Python SDK recommends a one-time download step after installation:
6+
7+
```bash
8+
python -m copilot download-runtime
9+
```
10+
11+
This downloads the matching runtime and caches it locally. If you skip this step, the SDK will attempt to download it automatically on first use as a fallback.
412

513
**Best for:** Most applications—desktop apps, standalone tools, CLI utilities, prototypes, and more.
614

715
## How it works
816

9-
When you install the SDK, the Copilot CLI binary is included automatically. The SDK starts it as a child process and communicates over stdio. There's nothing extra to configure.
17+
When you install the SDK, the Copilot runtime is included automatically (Node.js, .NET) or downloaded via `python -m copilot download-runtime` (Python). The SDK starts it as a child process and communicates over stdio. There's nothing extra to configure.
1018

1119
```mermaid
1220
flowchart TB

docs/setup/local-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local CLI setup
22

3-
Use a specific CLI binary instead of the SDK's bundled CLI. This is an advanced option—you supply the CLI path explicitly, and you are responsible for ensuring version compatibility with the SDK.
3+
Use a specific CLI binary instead of the SDK's automatic CLI management. This is an advanced option—you supply the CLI path explicitly, and you are responsible for ensuring version compatibility with the SDK.
44

55
**Use when:** You need to pin a specific CLI version, or work with the Go SDK (which does not bundle a CLI).
66

python/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,3 @@ uv.lock
169169
# Build script caches
170170
.cli-cache/
171171
.build-temp/
172-
173-
# Bundled CLI binary (only in platform wheels, not in repo)
174-
copilot/bin/

python/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ To include OpenTelemetry support:
2020
pip install "github-copilot-sdk[telemetry]"
2121
```
2222

23+
## Runtime
24+
25+
Published wheels include a pinned runtime version. After installing, download the
26+
runtime:
27+
28+
```bash
29+
python -m copilot download-runtime
30+
```
31+
32+
This caches the runtime binary locally. If you skip this step, the SDK will
33+
attempt to download it automatically on first use as a fallback.
34+
35+
| Platform | Cache path |
36+
|----------|-----------|
37+
| Linux | `~/.cache/github-copilot-sdk/cli/<version>/copilot` |
38+
| macOS | `~/Library/Caches/github-copilot-sdk/cli/<version>/copilot` |
39+
| Windows | `%LOCALAPPDATA%\github-copilot-sdk\cli\<version>\copilot.exe` |
40+
41+
### Environment variables
42+
43+
| Variable | Description |
44+
|----------|-------------|
45+
| `COPILOT_CLI_PATH` | Use this specific binary instead of downloading |
46+
| `COPILOT_CLI_CACHE_DIR` | Override the default cache directory (version subdirectory still appended) |
47+
| `COPILOT_SKIP_CLI_DOWNLOAD` | Set to `1` to disable auto-download |
48+
| `COPILOT_CLI_DOWNLOAD_BASE_URL` | Override the GitHub Releases download URL |
49+
2350
## Run the Sample
2451

2552
Try the interactive chat sample (from the repo root):

python/copilot/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Entry point for `python -m copilot`."""
2+
3+
from ._cli_download import main
4+
5+
if __name__ == "__main__":
6+
main()

0 commit comments

Comments
 (0)