Install Pystrano
Pystrano is published on PyPI and currently requires Python 3.12 or newer.
pip install pystrano
Create a deployment config
By default, Pystrano reads a YAML file from this path:
deploy/<app_name>/<environment_name>/deployment.yml
For an app named api and an environment named production, generate:
deploy/api/production/deployment.yml
The init flow prompts for Django or FastAPI, package manager, repository, server, and systemd details. It also writes a starter gunicorn.service or uvicorn.service file referenced by the generated config.
pystrano init production api
pystrano configure production api is accepted as an alias. Use --deploy-config-dir and --config-file-name when your deployment files live outside the default path.
Configure SSH and server access
The setup command connects as root. The deploy command connects as the configured project_user. Make sure your local SSH keys, remote access, Git host access, and any referenced local files are ready before running live commands.
Preview setup
Use --dry-run first to print commands without executing them.
pystrano setup production api --dry-run
Run setup
Setup creates the deploy user, copies authorized SSH keys, prepares directories, installs packages, creates the virtualenv, updates known hosts, installs uv when configured, and optionally registers a systemd service and uploads secret files.
pystrano setup production api
Deploy
Preview the deploy first, then run it when the output matches your expectations.
pystrano deploy production api --dry-run
pystrano deploy production api
Choose the framework path
For Django, Pystrano can run manage.py migrate and manage.py collectstatic --noinput. For FastAPI, migrations default to Alembic and can be customized with migration_command; static asset work requires static_files_command when enabled.
Roll back
Pystrano does not currently expose a rollback CLI command. Deployments use timestamped release directories and a current symlink, so rollback is a manual server recovery procedure today. See the rollback guide before relying on this in production.
Next steps
Read the Django or FastAPI VPS guide for a complete deployment flow, then review the configuration and secrets pages before using Pystrano with sensitive production systems.