Vercel CLI packaged for Python (bundled Node.js, vendored npm)
Project description
Python package wrapper for Vercel CLI
vercel-cli packages the npm vercel CLI for Python environments. It vendors the npm package under vercel_cli/vendor/ and uses the bundled Node.js runtime provided by nodejs-wheel-binaries, so you can run vercel without installing Node.js.
It provides both a command-line interface and a Python API that other libraries can use programmatically instead of resorting to subprocess calls.
Quick start
- Install:
pip install vercel-cli
- Use (same arguments and behavior as the official npm CLI):
vercel --version
vercel login
vercel deploy
- Use programmatically in Python (for libraries that depend on this package):
from vercel_cli import run_vercel
# Deploy current directory
exit_code = run_vercel(["deploy"])
# Deploy specific directory with custom environment
exit_code = run_vercel(
["deploy", "--prod"],
cwd="/path/to/project",
env={"VERCEL_TOKEN": "my-token"}
)
# Check version
exit_code = run_vercel(["--version"])
What this provides
- No system Node.js required: The CLI runs via the Node binary from
nodejs-wheel-binaries(currently Node 22.x). - Vendored npm package: The
vercelnpm package (production deps only) is checked intovercel_cli/vendor/. - Console entrypoint: The
vercelcommand maps tovercel_cli.run:main, which executesvercel_cli/vendor/dist/vc.jswith the bundled Node runtime. - Python API: The
run_vercel()function allows other Python libraries to use Vercel CLI programmatically without subprocess calls, with secure environment variable handling.
Requirements
- Python 3.8+
- macOS, Linux, or Windows supported by the Node wheels
How it works
At runtime, vercel_cli.run locates vercel_cli/vendor/dist/vc.js and launches it via the Node executable exposed by nodejs_wheel_binaries. CLI arguments are passed through unchanged, while environment variables are handled securely.
Programmatic usage
When using this package as a dependency in other Python libraries, you can call Vercel CLI commands directly without using subprocess:
from vercel_cli import run_vercel
import tempfile
import os
def deploy_my_app(source_dir: str, token: str) -> bool:
"""Deploy an application to Vercel programmatically."""
with tempfile.TemporaryDirectory() as temp_dir:
# Copy your app to temp directory and modify as needed
# ...
# Deploy with custom environment
env = {
"VERCEL_TOKEN": token,
"NODE_ENV": "production"
}
exit_code = run_vercel(
["deploy", "--prod", "--yes"],
cwd=temp_dir,
env=env
)
return exit_code == 0
# Usage
success = deploy_my_app("./my-app", "my-vercel-token")
The run_vercel() function accepts:
args: List of CLI arguments (same as command line)cwd: Working directory for the commandenv: Environment variables to set (passed directly to the Node.js runtime)
Security considerations
When using the env parameter, only explicitly provided environment variables are passed to the Vercel CLI. This prevents accidental leakage of sensitive environment variables from your Python process while still allowing you to set necessary variables like VERCEL_TOKEN.
Example with secure token handling:
from vercel_cli import run_vercel
# Secure: only VERCEL_TOKEN is passed to the CLI
exit_code = run_vercel(
["deploy", "--prod"],
env={"VERCEL_TOKEN": "your-secure-token"}
)
This approach avoids common security pitfalls of subprocess environment variable handling.
Updating the vendored Vercel CLI (maintainers)
There are two ways to update the vendored npm package under vercel_cli/vendor/:
- Manual update to a specific version
# Using the console script defined in pyproject.toml
uv run update-vendor 46.0.2
# or equivalently
uv run python scripts/update_vendor.py 46.0.2
This will:
- fetch
vercel@46.0.2from npm, - verify integrity/shasum,
- install production dependencies with
npm install --omit=dev, and - copy the result into
vercel_cli/vendor/.
- Automatic check-and-release (GitHub Actions)
The workflow .github/workflows/release.yml checks npm latest and, if newer than the vendored version, will:
- vendor the new version using
scripts/check_and_update.py, - commit the changes and create a tag
v<version>, - build distributions, and
- publish to PyPI (requires
PYPI_API_TOKEN).
Versioning
The Python package version is derived dynamically from the vendored package.json via Hatch’s version source:
[tool.hatch.version]
path = "vercel_cli/vendor/package.json"
pattern = '"version"\s*:\s*"(?P<version>[^\\"]+)"'
Development
- Build backend:
hatchling - Dependency management:
uv(seeuv.lock) - Tests:
pytestwith coverage intests/ - Lint/format:
ruff; type-check:basedpyright
Common commands (using uv):
# Run tests with coverage
uv run pytest --cov=vercel_cli --cov-report=term-missing
# Lint and format
uv run ruff check .
uv run ruff format .
# Type-check
uv run basedpyright
# Build wheel and sdist
uv run --with build python -m build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vercel_cli-49.2.0.tar.gz.
File metadata
- Download URL: vercel_cli-49.2.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f6f6177c44b58f76c086d844839726796793899df738cad8147fdcebfb56b90
|
|
| MD5 |
f38076d6972cc1fca823fc17b8c2e0fe
|
|
| BLAKE2b-256 |
1fce0c99fb85c296237907f12ee411d5cd0e5db52b2a646042d548d09044e66d
|
Provenance
The following attestation bundles were made for vercel_cli-49.2.0.tar.gz:
Publisher:
release.yml on nuage-studio/vercel-cli-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vercel_cli-49.2.0.tar.gz -
Subject digest:
9f6f6177c44b58f76c086d844839726796793899df738cad8147fdcebfb56b90 - Sigstore transparency entry: 758745946
- Sigstore integration time:
-
Permalink:
nuage-studio/vercel-cli-python@1ca703b234261a5b4d7dc248929a0b032b0323b1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nuage-studio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1ca703b234261a5b4d7dc248929a0b032b0323b1 -
Trigger Event:
schedule
-
Statement type:
File details
Details for the file vercel_cli-49.2.0-py3-none-any.whl.
File metadata
- Download URL: vercel_cli-49.2.0-py3-none-any.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cfed0f44d26c1e4ee3d9d5f94ae97bc85634abfaf88b7b365940a9e8469e7dc
|
|
| MD5 |
933177377fc16d86436d9c3a9921a058
|
|
| BLAKE2b-256 |
4a5f35303872250d076da18b5d4c86aa028403d990350d1c9e18e3edd6762f10
|
Provenance
The following attestation bundles were made for vercel_cli-49.2.0-py3-none-any.whl:
Publisher:
release.yml on nuage-studio/vercel-cli-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vercel_cli-49.2.0-py3-none-any.whl -
Subject digest:
9cfed0f44d26c1e4ee3d9d5f94ae97bc85634abfaf88b7b365940a9e8469e7dc - Sigstore transparency entry: 758745978
- Sigstore integration time:
-
Permalink:
nuage-studio/vercel-cli-python@1ca703b234261a5b4d7dc248929a0b032b0323b1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nuage-studio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1ca703b234261a5b4d7dc248929a0b032b0323b1 -
Trigger Event:
schedule
-
Statement type: