python: thin Python client (pip install capcut) over the CLI and its JSONL queue - #125
Merged
Merged
Conversation
capcut.run(cmd, *args, **flags) spawns the CLI once without a shell and returns the JSON it prints; keyword arguments become flags, positionals pass through as single argv tokens, a non-zero exit raises CommandError with the status and the CLI's own JSON. capcut.serve(jobs) feeds the stateless JSONL queue and returns one result per job; describe(), doctor(), version(). Output is captured to files, not pipes, so documents past the 64 KiB pipe buffer arrive whole. Pure Python, no dependencies, Python >= 3.9. Not part of the npm tarball.
renezander030
force-pushed
the
python-client
branch
from
September 19, 2026 15:53
40cf37c to
f3ba05b
Compare
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.
What
python/— a pure-Python package,capcuton PyPI, that wraps the installed CLI.capcut.run(cmd, *args, **flags)spawnscapcutonce, without a shell, and returns the JSON it prints. Keyword arguments become flags (font_size=16→--font-size 16,karaoke=True→--karaoke, lists repeat,None/Falsedrop). Positionals pass through as single argv tokens, so Chinese text, spaces and quotes never need escaping. A non-zero exit raisesCommandErrorwithstatusand the CLI's own{"error": ...}(read from stderr when stdout is empty).run_rawnever raises.capcut.serve(jobs, workers=…)feeds the stateless JSONL queue and returns one parsed result per job; a failed job isok: false, not an exception.describe(),doctor()(returned even on exit 1),version(),human=Truefor-Htext.CAPCUT_CLI(a command line, e.g.node …/dist/index.js); a missing binary raisesCliNotFoundwith the npm install line in Chinese and English.describe(93 KB) was cut at the 64 KiB pipe buffer on exit, the same effect the repo'sspawn-clitest helper works around.README in Chinese first, English second (it is the PyPI page). Root READMEs point at it from the install block. Not in the npm tarball (
fileswhitelist unchanged). No runtime dependencies on either side.Checks
python -m unittest discover -s tests: 11 tests against a stand-in binary (flag conversion, unicode positionals, error propagation,-H, version, doctor on exit 1, serve round trip, missing-binary message).python -m build; the wheel installed into a clean venv and run against the built CLI: quickstart 9:16, add-text with Chinese and quotes, lint, info on a missing path (CommandError with the CLI's message), serve with two jobs, describe (86 commands), doctor,-H.python -m build && twine upload dist/*frompython/when this merges.Docs
python/README.md, install pointers in README.md and README.zh-CN.md, CHANGELOG (Unreleased),.gitignorefor the build artifacts.