CLI Reference¶
Complete reference for the pylocket command-line tool (v1.1.19).
Install: pip install pylocket
Global Options¶
These options apply to all commands:
| Option | Description | Default |
|---|---|---|
--api-url <URL> |
Override the PyLocket API base URL | https://api.pylocket.com |
--token <TOKEN> |
Override the session token (the JWT from pylocket login) |
Read from ~/.pylocket/credentials |
--help, -h |
Show help for any command | — |
--version |
Show the CLI version | — |
The PYLOCKET_TOKEN environment variable can also be used instead of --token.
The PYLOCKET_API_URL environment variable can be used instead of --api-url.
--token is not your API key
It takes the session token issued by pylocket login, which expires
after 30 minutes. An API key passed here is rejected with 401, because the
CLI sends it as a Bearer credential and the server cannot decode it as a
JWT. API keys are for calling the REST API with the X-API-Key header; see
CI/CD Integration.
pylocket login¶
Authenticate with the PyLocket API.
Options¶
| Option | Description |
|---|---|
--email <EMAIL> |
Account email (prompted interactively if omitted) |
--password <PASSWORD> |
Account password (prompted interactively if omitted) |
--token <TOKEN> |
Authenticate directly with an existing session token, not an API key (skips interactive login) |
--sso |
Authenticate via browser (opens your default browser to the PyLocket portal) |
Behavior¶
- On success, stores credentials at
~/.pylocket/credentials - If 2FA is enabled, prompts for a TOTP code after password (or handles it in the browser with
--sso) - The stored token is reused for subsequent commands until it expires
Not for CI/CD
Every option here yields a session token that expires after 30 minutes, and the password form stops working once 2FA is enabled. For pipelines, use an API key against the REST API instead; see CI/CD Integration.
Browser-Based Login (--sso)¶
The --sso flag opens your default browser to the PyLocket portal for authentication. This is recommended if you:
- Have 2FA enabled and prefer entering your TOTP code in a browser
- Use a password manager that auto-fills browser forms
- Are on a shared machine and prefer not to type credentials in a terminal
After you sign in (including 2FA if enabled), the browser redirects back to the CLI automatically — no copy-pasting required. The CLI stores the credentials the same way as interactive login.
If the browser can't be opened (e.g., SSH session), the CLI prints the URL for you to open manually in any browser on the same machine.
Examples¶
# Interactive login (email/password in terminal)
pylocket login
# Browser-based login (recommended for 2FA users)
pylocket login --sso
# Non-interactive login (local scripts; fails once 2FA is enabled)
pylocket login --email dev@example.com --password "s3cret"
# Reuse a session token you already hold (expires after 30 minutes)
pylocket login --token "eyJhbGc..."
pylocket apps¶
Manage registered applications.
pylocket apps create¶
Register a new application.
| Option | Description | Required | Default |
|---|---|---|---|
--name <NAME>, -n |
Application display name | Yes | — |
--description <TEXT>, -d |
Application description | No | None |
--platform <PLATFORM>, -p |
Target platform | No | python |
pylocket apps list¶
List all registered applications.
| Option | Description | Default |
|---|---|---|
--page <N> |
Page number | 1 |
--page-size <N> |
Items per page | 20 |
pylocket apps update¶
Update an existing application.
| Option | Description |
|---|---|
--app <APP_ID> |
Application ID (required) |
--name <NAME> |
New display name |
--description <TEXT> |
New description |
Platform targets are fixed at creation time. The device limit lives in the app's license policy, which is edited in the Developer Portal — updating it through the API replaces the whole policy object, so it is not exposed as a CLI flag.
pylocket apps delete¶
Delete a registered application.
Warning: Deleting an app revokes all associated licenses and removes all builds. This action cannot be undone.
pylocket protect¶
Upload and protect an application artifact.
Options¶
| Option | Description | Required | Default |
|---|---|---|---|
--app <APP_ID> |
Application ID | Yes | — |
--artifact <PATH> |
Path to the artifact to protect | Yes | — |
--platform <PLATFORM> |
Target platform (e.g. win-x64, linux-x64, darwin-arm64) |
No | Auto-detected from your OS |
--python <VERSION> |
Python version used to build the artifact | No | Engine-detected from the artifact |
--version <LABEL> |
Build version label | No | 1.0.0 |
--wait / --no-wait |
Wait for the protection build to complete | No | --wait |
--out <DIR> |
Auto-download to this directory when ready (implies --wait) |
No | — |
Valid Python versions: 3.12, 3.13, 3.14
Platform auto-detection
If --platform is not specified, the CLI reads your current platform from sysconfig.get_platform() and maps it to a PyLocket platform token: win-amd64 becomes win-x64, linux-x86_64 becomes linux-x64, and Apple Silicon Macs become darwin-arm64. You only need to specify --platform when cross-protecting for a different OS.
Python version auto-detection
If --python is not specified, the protection engine detects the Python version from the uploaded artifact itself (for example the PyInstaller archive header or embedded interpreter markers). Pass --python only as a hint when that detection fails.
Supported Artifact Types¶
| Extension | Description |
|---|---|
.py, .pyz, .pyw |
Python scripts |
.whl |
Python wheels |
.zip |
ZIP archives (must contain Python files) |
.exe |
Windows executables (PyInstaller, cx_Freeze) |
.elf |
Linux ELF executables (PyInstaller onefile) |
.app |
macOS application bundles (zipped .app directory) |
Tar archives and eggs are not supported
Tar archives (.tar.gz, .tgz, .tar.bz2) and Python eggs (.egg) are not supported. CLI 1.1.21 still accepts and uploads them, and its Unsupported file type message still lists them. A tar archive's build fails with Unrecognised artifact format (see Build Errors); without --python it can fail first with Specify a Python version, and passing --python does not make it build. For a tar archive, zip the same tree and upload the .zip, or build a wheel (python -m build --wheel) and upload the .whl. For an egg, build the wheel: a zip of its tree is handled like the egg.
Note
PyInstaller onefile builds on Linux and macOS emit an extensionless binary. Rename it to .elf before running pylocket protect (the engine reads the real format from the bytes; for macOS GUI apps, upload the .app bundle instead).
Examples¶
# Protect an application (platform and Python version auto-detected)
pylocket protect \
--app 3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114 \
--artifact dist/myapp.exe
# Protect with explicit platform and Python version
pylocket protect \
--app 3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114 \
--artifact dist/myapp.exe \
--platform win-x64 \
--python 3.13
# Protect and auto-download when ready
pylocket protect \
--app 3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114 \
--artifact dist/myapp.exe \
--out dist/protected/
# Protect without waiting (check status later)
pylocket protect \
--app 3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114 \
--artifact dist/myapp.exe \
--no-wait
pylocket status¶
Check the status of a protection build.
Options¶
| Option | Description |
|---|---|
--build <BUILD_ID> |
Build ID to check |
--app <APP_ID> |
App ID (used with --latest) |
--latest |
Show the most recent build for the app |
--format <FORMAT> |
Output format: table (default), json |
Build Statuses¶
| Status | Description |
|---|---|
pending |
Build created and waiting for the protection worker |
processing |
Protection in progress |
ready |
Protection complete and ready for download |
failed |
An error occurred during protection |
rejected |
Artifact was flagged by the malware scan; the developer account is automatically suspended pending review |
Fine-grained progress (extraction, encryption, packaging) is reported in the separate processing_stage field of the build payload, not in status.
The table also has a Released row (CLI 1.1.21 or later): when you released the build, or No. For a ready build it prints the pylocket fetch command for that build, including with --latest.
Examples¶
# Check a specific build
pylocket status --build 7c2d5e91-0a36-4b8f-9e14-8d63f2a70c55
# Check the latest build for an app (JSON output)
pylocket status --app 3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114 --latest --format json
pylocket fetch¶
Download a protected artifact.
Options¶
| Option | Description | Required |
|---|---|---|
--build <BUILD_ID> |
Build ID to download | Yes |
--out <DIR> |
Output directory | Yes |
--app <APP_ID> |
App ID (optional, improves lookup speed) | No |
Example¶
The command creates the output directory if it does not exist.
Tip
The --app flag is optional. You can use just --build and the server will look up the build automatically.
pylocket release¶
Release a READY build to your customers, or undo a release. Requires CLI 1.1.21 or later.
Options¶
| Option | Description | Required |
|---|---|---|
--build <BUILD_ID> |
The build to release | Yes |
--app <APP_ID> |
The build's app. If omitted, the CLI looks it up from the build | No |
--undo |
Undo the build's release instead | No |
What a release changes depends on the app's delivery mode. In latest_ready (every app's default) customers get the newest READY build whether or not you released it, so a release only records your decision. In released_only they get only builds you released. See If your app serves only released builds.
Windows and macOS: sign before you release
PyLocket does not code-sign your app. Sign the protected build with your own certificate (and notarize it on macOS), then upload the signed copy with pylocket replace-signed before you release the build, or add --release to replace-signed, which releases the build only once the signed copy is accepted. A build you have not signed meets Windows SmartScreen and macOS Gatekeeper warnings or blocks, and the PyLocket Installer and Hub refuse to install it.
In latest_ready a new build reaches your customers as soon as protection finishes, before you have signed it. To make sure they only ever get the copy you signed, set the app to serve released builds only and use pylocket replace-signed <BUILD_ID> <SIGNED_PATH> --release.
The command prints the API's answer (POST .../release):
| Field | Meaning |
|---|---|
released |
Whether the build is released after the call, and when it was released |
changed |
no when the build was already in that state, so this call changed nothing. After a gateway error (502, 503, 504) or a timeout the CLI sends the call again, and that call can find the change its first attempt made |
delivery_mode |
The app's delivery mode, latest_ready or released_only |
serving_build_id |
The build customers on this build's platform get now, or none |
A refusal exits with code 1 and shows the API's message with its reason:
build_not_servable: only a READY build with a protected artifact can be released.active_push_target(with--undo): the build is the target of your app's active update push and the app serves only released builds. Clear the push first.
Release, unrelease and the delivery-mode switch share a limit of 30 calls a minute.
Examples¶
# Release a build
pylocket release --build 7c2d5e91-0a36-4b8f-9e14-8d63f2a70c55
# Undo it
pylocket release --build 7c2d5e91-0a36-4b8f-9e14-8d63f2a70c55 --undo
pylocket replace-signed¶
Replace a protected build's artifact with your code-signed copy. See Replace with Signed Package for when and why.
Arguments and options¶
| Argument or option | Description | Required |
|---|---|---|
<BUILD_ID> |
The protected build to replace | Yes |
<SIGNED_PATH> |
Your signed macOS .app (the CLI archives the directory with its symlinks preserved) or .app.zip, or your signed Windows .exe |
Yes |
--app-id <APP_ID> |
The build's app. If omitted, the CLI looks it up from the build | No |
--release |
Release the build once the replacement is confirmed (CLI 1.1.21 or later). Never after a refusal | No |
PyLocket checks the upload against the protected build before it replaces anything. A refusal exits with code 1 and shows what to fix; nothing is replaced, and with --release nothing is released.
If the check ends without an answer (a gateway error or a timeout), CLI 1.1.21 and later do not send it again, because it may still be running. The CLI prints Outcome unknown with the SHA-256 of the file it uploaded and exits with code 1. Run pylocket status --build <BUILD_ID>: a SHA-256 equal to the printed one means the replacement went through. Any other value means it has not, or not yet, so look again before you upload again. With --release, release the build with pylocket release once the SHA-256 matches.
Example¶
pylocket distribute¶
Generate a one-time direct download link for your application.
Options¶
| Option | Description | Required |
|---|---|---|
--app <APP_ID> |
Application ID | Yes |
Example¶
pylocket distribute --app 3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114
# Returns: https://get.pylocket.com/a1b2c3
The generated link is single-use and expires after 30 days. When an end user visits the link, they enter their details, download the app, and receive an auto-generated license. The first 10 downloads per app are free.
See Distribute Your App for the full distribution workflow.
pylocket licenses¶
Manage end-user licenses.
pylocket licenses create¶
Create a new license key.
This creates a billable license
Each license you create is charged the per-license fee on your next
invoice. The command asks for confirmation first; pass --yes to skip the
prompt in scripts.
On the Free plan you are not charged, but every license is issued as a
trial regardless of --type, and counts against your free-tier allowance.
Without --expires it expires in 30 days; an explicit --expires is
honored.
| Option | Description | Default |
|---|---|---|
--app <APP_ID> |
Application ID | (required) |
--email <EMAIL> |
End-user email | (optional) |
--device-limit <N> |
Max devices | 2 |
--expires <DATE> |
Expiration date (YYYY-MM-DD) | None (no expiry on Pro; 30 days on the Free plan) |
--type <TYPE> |
License type: standard, demo |
standard |
--channel <CHANNEL> |
Sales channel recorded on the license, used for billing reconciliation: manual, api, stripe, appsumo, gumroad, paddle, lemonsqueezy |
manual |
--yes, -y |
Skip the billing confirmation prompt | off |
pylocket licenses list¶
List licenses. Omit --app to list across every app you own.
| Option | Description |
|---|---|
--app <APP_ID> |
Filter to one application (optional) |
--type <TYPE> |
Filter by type: trial, paid |
--format <FORMAT> |
Output format: table, json |
pylocket licenses get¶
Get details for a specific license.
pylocket licenses revoke¶
Revoke a license.
pylocket licenses reset-devices¶
Clear all device activations for a license.
pylocket licenses extend¶
Extend a license expiration date. Requires an active Pro subscription — on the Free plan this returns "Active Pro subscription required to edit license expiry dates or download caps".
pylocket auth¶
Manage authentication and security settings.
pylocket auth api-keys rotate¶
Generate a new API key and invalidate the old one.
pylocket auth 2fa setup¶
Start 2FA setup. Returns a QR code URI for your authenticator app.
pylocket auth 2fa confirm¶
Confirm 2FA setup with a TOTP code.
pylocket auth 2fa status¶
Check 2FA status and remaining backup codes.
pylocket auth 2fa disable¶
Disable 2FA.
pylocket webhook¶
Configure build event webhooks for CI/CD integration.
pylocket webhook set¶
Configure a webhook URL to receive build event notifications.
Returns a webhook secret that must be saved immediately — it cannot be retrieved again. PyLocket will POST a signed JSON payload to this URL when a build completes, fails, or is rejected, and when you release or unrelease one. The command prints the events the API lists for the webhook; CLI 1.1.20 and earlier print only the first three, although the webhook receives all five. See Webhooks for the events and their payloads.
pylocket webhook remove¶
Remove the webhook configuration for an app.
pylocket webhook test¶
Send a test ping event to verify the webhook URL is reachable.
pylocket webhook status¶
Show webhook configuration and recent delivery attempts.
Environment Variables¶
| Variable | Description | Equivalent Option |
|---|---|---|
PYLOCKET_TOKEN |
Authentication token | --token |
PYLOCKET_API_URL |
API base URL | --api-url |
PYLOCKET_LICENSE_KEY |
License key for protected apps (used at runtime) | — |
PYLOCKET_FORCE_INCLUDE |
No effect with the hosted service (the engine runs on PyLocket's infrastructure, not your machine). Declare selection in pylocket.toml or with --protect. |
— |
PYLOCKET_FORCE_EXCLUDE |
Comma-separated module names to never protect. Same caveat as above — use pylocket.toml or the build API's force_exclude. |
— |
PYLOCKET_DEBUG |
Set to 1 to enable verbose bootstrap debug logging |
— |
Exit Codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
General error |
2 |
Timeout waiting for build completion |
130 |
User abort (Ctrl+C) |
Credential Storage¶
Credentials are stored at ~/.pylocket/credentials in JSON format. The file contains:
- Access token (JWT, expires after the configured TTL)
- Refresh token
- API URL
The file permissions are set to 600 (owner read/write only).
To clear stored credentials: