pybun-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 VOID TECHNOLOGY INC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include LICENSE
2
+ include README.md
@@ -0,0 +1,480 @@
1
+ Metadata-Version: 2.4
2
+ Name: pybun-cli
3
+ Version: 0.1.0
4
+ Summary: PyBun shim bootstrapper for signed releases
5
+ Author: PyBun Authors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pybun/pybun
8
+ Project-URL: Repository, https://github.com/pybun/pybun
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # PyBun (Python Bundle)
22
+
23
+ A Rust-based single-binary Python toolchain. Integrates fast dependency installation, runtime/import optimization, testing, build capabilities, and AI agent-friendly JSON output.
24
+
25
+ ## Status
26
+ - Current: Implementation of M1 (Fast Installer), M2 (Runtime Optimization), and M4 (MCP/JSON) is in progress (**stable/preview/stub mixed**)
27
+ - Platforms: macOS/Linux (arm64/amd64), Windows (preview)
28
+
29
+ ※ For feature maturity (stub/preview/stable) and phased rollout policy, see `docs/SPECS.md`.
30
+
31
+ ## Installation
32
+
33
+ Installers default to the latest stable release manifest (signatures + `release_notes`). Pin a specific manifest with `PYBUN_INSTALL_MANIFEST` when running in CI or offline builds.
34
+
35
+ ```bash
36
+ # Homebrew (macOS / Linux)
37
+ brew tap pybun/pybun https://github.com/pybun/pybun
38
+ brew install pybun
39
+
40
+ # macOS / Linux (one-liner installer)
41
+ curl -LsSf https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.sh | sh
42
+
43
+ # Nightly channel
44
+ curl -LsSf https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.sh | sh -s -- --channel nightly
45
+
46
+ # Custom prefix
47
+ curl -LsSf https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.sh | sh -s -- --prefix ~/.local
48
+ ```
49
+
50
+ ```powershell
51
+ # Windows (Scoop)
52
+ scoop bucket add pybun https://github.com/pybun/pybun
53
+ scoop install pybun
54
+
55
+ # Windows (winget)
56
+ winget install PyBun.PyBun
57
+
58
+ # Windows (PowerShell installer)
59
+ irm https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.ps1 | iex
60
+
61
+ # With options
62
+ & ([scriptblock]::Create((irm https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.ps1))) -Channel nightly -Prefix "$env:LOCALAPPDATA\pybun"
63
+ ```
64
+
65
+ ```bash
66
+ # PyPI shim (pipx / pip)
67
+ # Package name on PyPI is `pybun-cli` (module/command stays `pybun`)
68
+ pipx install pybun-cli
69
+ # or
70
+ pip install --user pybun-cli
71
+ ```
72
+ The PyPI shim downloads and verifies the signed release binary on first run.
73
+
74
+ > Heads up: PyBun ships a `pybun-cli` alias in every channel (Homebrew/Scoop/winget/install.sh/pip). If your PATH already resolves `pybun` to Bun, use `pybun-cli` or move PyBun earlier in PATH.
75
+
76
+ ```bash
77
+ # Development (from source)
78
+ cargo install --path .
79
+ ```
80
+
81
+ ## GA Quickstart
82
+
83
+ 1) Install the stable build with a pinned manifest (includes signatures + release notes):
84
+ ```bash
85
+ export PYBUN_INSTALL_MANIFEST="https://github.com/pybun/pybun/releases/latest/download/pybun-release.json"
86
+ curl -LsSf https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.sh | sh
87
+ # Windows (PowerShell)
88
+ irm https://raw.githubusercontent.com/pybun/pybun/main/scripts/install.ps1 | iex
89
+ ```
90
+ `--format=json` on the installer surfaces the manifest, chosen asset, and `release_notes` attachment for CI logs.
91
+
92
+ 2) Initialize a project (pyproject + lock):
93
+ ```bash
94
+ cat > pyproject.toml <<'EOF'
95
+ [project]
96
+ name = "hello-pybun"
97
+ version = "0.1.0"
98
+ dependencies = ["requests>=2.31"]
99
+ EOF
100
+
101
+ pybun install --require requests==2.31.0 --lock pybun.lockb
102
+ ```
103
+
104
+ 3) Add or resolve dependencies:
105
+ ```bash
106
+ pybun add httpx
107
+ pybun install --index fixtures/index.json
108
+ ```
109
+
110
+ 4) Run / test / build with JSON for automation:
111
+ ```bash
112
+ pybun --format=json run -c -- "print('Hello, PyBun!')" # add --sandbox for untrusted code
113
+ pybun --format=json test --fail-fast
114
+ pybun --format=json build
115
+ ```
116
+
117
+ 5) Self-update and verify release metadata:
118
+ ```bash
119
+ pybun --format=json self update --channel stable --dry-run
120
+ ```
121
+
122
+ ## Command Reference
123
+
124
+ ### Package Management
125
+
126
+ ```bash
127
+ # Install dependencies (generates lockfile)
128
+ pybun install --require requests==2.31.0 --index fixtures/index.json
129
+
130
+ # Add a package (updates pyproject.toml)
131
+ pybun add requests
132
+
133
+ # Remove a package
134
+ pybun remove requests
135
+ ```
136
+
137
+ ### Script Execution
138
+
139
+ ```bash
140
+ # Run a Python script
141
+ pybun run script.py
142
+
143
+ # Run with arguments
144
+ pybun run script.py -- arg1 arg2
145
+
146
+ # Run inline code
147
+ pybun run -c -- "import sys; print(sys.version)"
148
+
149
+ # Run with profile
150
+ pybun run --profile=prod script.py
151
+ ```
152
+
153
+ PEP 723 inline metadata is also supported:
154
+ ```python
155
+ # /// script
156
+ # requires-python = ">=3.11"
157
+ # dependencies = ["requests>=2.28"]
158
+ # ///
159
+ import requests
160
+ ```
161
+ ※ Currently, **metadata parsing and display are the main features (preview)**, with auto-install and isolated environment execution planned for phased rollout (see `docs/PLAN.md` for details).
162
+
163
+ ### Ad-hoc Execution (`pybun x`)
164
+
165
+ Install a package in a temporary environment and execute it (Python version of `npx`):
166
+
167
+ ```bash
168
+ # Temporarily install and run cowsay
169
+ pybun x cowsay
170
+
171
+ # Specify version
172
+ pybun x cowsay==6.1
173
+
174
+ # With arguments
175
+ pybun x black -- --check .
176
+ ```
177
+
178
+ ### Python Version Management
179
+
180
+ ```bash
181
+ # Show installed versions
182
+ pybun python list
183
+
184
+ # Show all available versions
185
+ pybun python list --all
186
+
187
+ # Install Python
188
+ pybun python install 3.12
189
+
190
+ # Remove Python
191
+ pybun python remove 3.12
192
+
193
+ # Show Python path
194
+ pybun python which
195
+ pybun python which 3.11
196
+ ```
197
+
198
+ ### Runtime Optimization
199
+
200
+ #### Module Finder
201
+
202
+ Rust-based high-speed module search:
203
+
204
+ ```bash
205
+ # Find a module
206
+ pybun module-find os.path
207
+
208
+ # Scan a directory for all modules
209
+ pybun module-find --scan -p ./src
210
+
211
+ # With benchmark
212
+ pybun module-find --benchmark os.path
213
+ ```
214
+
215
+ #### Lazy Import
216
+
217
+ ```bash
218
+ # Show configuration
219
+ pybun lazy-import --show-config
220
+
221
+ # Check module decision
222
+ pybun lazy-import --check numpy
223
+
224
+ # Generate Python code
225
+ pybun lazy-import --generate -o lazy_setup.py
226
+
227
+ # Specify allow/deny lists
228
+ pybun lazy-import --allow mymodule --deny debug_tools --generate
229
+ ```
230
+
231
+ #### File Watch (Development Mode)
232
+
233
+ ```bash
234
+ # Watch for file changes and re-run (currently preview)
235
+ # Native watching is planned for phased rollout. For now, use --shell-command (external watcher).
236
+ pybun watch main.py
237
+
238
+ # Watch a specific directory
239
+ pybun watch main.py -p src
240
+
241
+ # Show configuration
242
+ pybun watch --show-config
243
+
244
+ # Generate shell command for external watcher
245
+ pybun watch --shell-command main.py
246
+ ```
247
+
248
+ ### Profile Management
249
+
250
+ ```bash
251
+ # Show available profiles
252
+ pybun profile --list
253
+
254
+ # Show profile settings
255
+ pybun profile dev --show
256
+
257
+ # Compare profiles
258
+ pybun profile dev --compare prod
259
+
260
+ # Export profile
261
+ pybun profile prod -o prod-config.toml
262
+ ```
263
+
264
+ Profiles:
265
+ - `dev`: Hot reload enabled, verbose logging
266
+ - `prod`: Lazy imports enabled, optimizations
267
+ - `benchmark`: Tracing and timing measurement
268
+
269
+ ### MCP Server
270
+
271
+ MCP server for AI agents:
272
+
273
+ ```bash
274
+ # Start in stdio mode
275
+ pybun mcp serve --stdio
276
+ ```
277
+
278
+ Tools: `pybun_resolve`, `pybun_install`, `pybun_run`, `pybun_gc`, `pybun_doctor`
279
+ Resources: `pybun://cache/info`, `pybun://env/info`
280
+
281
+ ※ Currently **`pybun_gc`, `pybun_doctor`, `pybun_run`, `pybun_resolve`, and resources are operational**. `pybun_install` generates lockfiles via resolution. HTTP mode is not yet implemented.
282
+
283
+ ### Diagnostics & Maintenance
284
+
285
+ ```bash
286
+ # Environment diagnostics
287
+ pybun doctor
288
+ pybun doctor --verbose
289
+
290
+ # Cache garbage collection
291
+ pybun gc
292
+ pybun gc --max-size 1G
293
+ pybun gc --dry-run
294
+
295
+ # Self-update check
296
+ pybun self update --dry-run
297
+ pybun self update --channel nightly
298
+ ```
299
+
300
+ ## Sandbox usage
301
+
302
+ Use the sandbox for untrusted scripts or PEP 723 snippets:
303
+ ```bash
304
+ pybun --format=json run --sandbox examples/hello.py
305
+ pybun --format=json run --sandbox --allow-network -c "print('net ok')"
306
+ ```
307
+ The sandbox isolates file and network access; add `--allow-network` only when required. Combine with `--profile=prod` for production-like runs.
308
+
309
+ ## Profiles
310
+
311
+ Profiles tune defaults for performance vs. development ergonomics:
312
+ - `dev` (default): hot reload enabled, verbose logging.
313
+ - `prod`: lazy imports and optimizations enabled, quieter output.
314
+ - `benchmark`: stable timing/logging for reproducible benchmarks.
315
+
316
+ Examples:
317
+ ```bash
318
+ pybun profile --list
319
+ pybun run --profile=prod app.py
320
+ pybun test --profile=benchmark --format=json
321
+ ```
322
+
323
+ ## MCP server (stdio)
324
+
325
+ Operate PyBun as an MCP server for agents/IDEs:
326
+ ```bash
327
+ pybun mcp serve --stdio
328
+ pybun --format=json mcp serve --stdio # JSON envelope for tooling
329
+ ```
330
+ Tools: `pybun_resolve`, `pybun_install`, `pybun_run`, `pybun_gc`, `pybun_doctor`. Resources: `pybun://cache/info`, `pybun://env/info`. HTTP mode remains TODO; stdio is the GA path.
331
+
332
+ ## JSON output examples
333
+
334
+ All commands support the `--format=json` option (schema v1). Examples:
335
+
336
+ ```bash
337
+ pybun --format=json run -c -- "print('hello')"
338
+ ```
339
+
340
+ ```json
341
+ {
342
+ "version": "1",
343
+ "command": "pybun run",
344
+ "status": "ok",
345
+ "detail": {
346
+ "summary": "executed inline code"
347
+ },
348
+ "events": [],
349
+ "diagnostics": []
350
+ }
351
+ ```
352
+
353
+ Failure example:
354
+ ```bash
355
+ pybun --format=json run missing.py
356
+ ```
357
+
358
+ ```json
359
+ {
360
+ "version": "1",
361
+ "command": "pybun run",
362
+ "status": "error",
363
+ "diagnostics": [
364
+ {
365
+ "kind": "runtime",
366
+ "message": "missing.py not found",
367
+ "hint": "pass -c for inline code or a valid path"
368
+ }
369
+ ]
370
+ }
371
+ ```
372
+
373
+ Tests/builds emit structured summaries (pass/fail counts, shard info) while keeping the same envelope:
374
+ ```bash
375
+ pybun --format=json test --fail-fast
376
+ pybun --format=json build
377
+ ```
378
+
379
+ Enable trace IDs for debugging:
380
+ ```bash
381
+ PYBUN_TRACE=1 pybun --format=json run script.py
382
+ ```
383
+
384
+ ## Environment Variables
385
+
386
+ | Variable | Description |
387
+ |----------|-------------|
388
+ | `PYBUN_ENV` | Path to venv to use |
389
+ | `PYBUN_PYTHON` | Path to Python binary |
390
+ | `PYBUN_PROFILE` | Default profile (dev/prod/benchmark) |
391
+ | `PYBUN_TRACE` | Set to `1` to enable trace ID |
392
+ | `PYBUN_LOG` | Log level (debug/info/warn/error) |
393
+
394
+ ## Release note automation
395
+
396
+ - Generate GA release notes from tags:
397
+ `python scripts/release/generate_release_notes.py --repo . --previous-tag v0.1.0 --tag v0.2.0 --notes-output release/RELEASE_NOTES.md --changelog CHANGELOG.md`
398
+ - Attach the notes to the release manifest (served by installers/self-update via `release_notes` in JSON):
399
+ `python scripts/release/generate_manifest.py --assets-dir release --version 0.2.0 --channel stable --base-url https://github.com/pybun/pybun/releases/download/v0.2.0 --output pybun-release.json --release-notes release/RELEASE_NOTES.md`
400
+ - CI-friendly JSON summary: `python scripts/release/generate_release_notes.py --repo . --previous-tag v0.1.0 --tag v0.2.0 --format json`
401
+
402
+ ## Upgrade guide
403
+
404
+ See `docs/UPGRADE.md` for pre-GA → GA migration notes, breaking changes, and the recommended CI checks (doc lint/link + release note automation).
405
+
406
+ ## Development
407
+
408
+ ### Requirements
409
+
410
+ - Rust stable (`rustup`, `cargo`)
411
+
412
+ ### Basic Commands
413
+
414
+ ```bash
415
+ # Format
416
+ cargo fmt
417
+
418
+ # Lint
419
+ cargo clippy --all-targets --all-features -- -D warnings
420
+
421
+ # Test
422
+ cargo test
423
+
424
+ # Development scripts
425
+ ./scripts/dev fmt
426
+ ./scripts/dev lint
427
+ ./scripts/dev test
428
+ ```
429
+
430
+ ### Testing
431
+
432
+ ```bash
433
+ # All tests
434
+ cargo test
435
+
436
+ # Specific tests
437
+ cargo test cli_smoke
438
+ cargo test json_schema
439
+ cargo test mcp
440
+ ```
441
+
442
+ ## Roadmap
443
+
444
+ - [x] M0: Repository & CI scaffold
445
+ - [x] M1: Fast installer (lockfile, resolver, PEP 723)
446
+ - [x] M2: Runtime optimization (module finder, lazy import, hot reload)
447
+ - [ ] M3: Test runner (discovery, parallel execution, snapshots)
448
+ - [x] M4: JSON/MCP & diagnostics
449
+ - [ ] M5: Builder & security
450
+ - [ ] M6: Remote cache, workspaces
451
+
452
+ See `docs/PLAN.md` for details.
453
+
454
+ ## Privacy & Telemetry
455
+
456
+ PyBun does **not** collect telemetry by default (opt-in model).
457
+
458
+ ```bash
459
+ # Check telemetry status
460
+ pybun telemetry status
461
+
462
+ # Enable telemetry
463
+ pybun telemetry enable
464
+
465
+ # Disable telemetry
466
+ pybun telemetry disable
467
+ ```
468
+
469
+ **Collected data (when enabled):**
470
+ - Command usage (anonymized)
471
+ - Error diagnostics
472
+ - Performance metrics
473
+
474
+ **Never collected:** API keys, tokens, credentials, passwords, or file contents.
475
+
476
+ Environment override: `PYBUN_TELEMETRY=0|1`
477
+
478
+ ## License
479
+
480
+ MIT