Skip to main content

English | 简体中文

pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands. Think ansible but Python instead of YAML, and a lot faster.


Getting Started • Examples Repo • Chat on Matrix

Documentation • Help & Support • Contributing


Why pyinfra? Design features include:

  • 🚀 Super fast execution over thousands of hosts with predictable performance.
  • 🚨 Instant debugging with realtime stdin/stdout/stderr output (-vvv).
  • 🔄 Idempotent operations that enable diffs and dry runs before making changes.
  • 📦 Extendable with the entire Python package ecosystem.
  • 💻 Agentless execution against anything with shell access.
  • 🔌 Integrated with connectors for Docker, Terraform, Vagrant and more.

Quickstart

Install pyinfra with uv:

uv tool install pyinfra

Now you can execute commands on hosts via SSH:

pyinfra my-server.net exec -- echo "hello world"

Or target Docker containers, the local machine, and other connectors:

pyinfra @docker/ubuntu exec -- echo "Hello world"
pyinfra @local exec -- echo "Hello world"

As well as executing commands you can define state using operations:

# Install iftop apt package if not present
pyinfra @docker/ubuntu apt.packages iftop update=true _sudo=true

Which can then be saved as a Python file like deploy.py:

from pyinfra.operations import apt

apt.packages(
    name="Ensure iftop is installed",
    packages=['iftop'],
    update=True,
    _sudo=True,
)

The hosts can also be saved in a file, for example inventory.py:

targets = ["@docker/ubuntu", "my-test-server.net"]

And executed together:

pyinfra inventory.py deploy.py

Now you know the building blocks of pyinfra! By combining inventory, operations and Python code you can deploy anything.

See the more detailed getting started or using operations guides. See how to use inventory & data, global arguments and the CLI or check out the documented examples.


PyPI version PyPi downloads Docs status Execute tests status Codecov Coverage MIT Licensed

Metadata

Release files for pyinfra 3.11.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyinfra 3.11.3
File Size Uploaded Provenance Actions
pyinfra-3.11.3.tar.gz 802.6 kB Without provenance Details for pyinfra-3.11.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyinfra 3.11.3
File Interpreter ABI Platform Actions
pyinfra-3.11.3-py3-none-any.whl Python 3 none any Details for pyinfra-3.11.3-py3-none-any.whl

Total release size: 1.2 MB

Release files / pyinfra-3.11.3.tar.gz

Download URL pyinfra-3.11.3.tar.gz
Size 802.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7949c744c5fb5fee73d6c44bab8c1a50c92bc47190ad6b8989a034fc905137f9
BLAKE2b-256 checksum
How to use checksums
1f198c054b7bb469ed2186794a15809f5742157fb22835a59e128ba3f64542c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pyinfra-3.11.3-py3-none-any.whl

Download URL pyinfra-3.11.3-py3-none-any.whl
Size 359.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
285cb8b4fd5836c642ce4df31415b1cb5993af3eaac4a8a00c98fc086457113d
BLAKE2b-256 checksum
How to use checksums
f2568dcfe620a96f7f6e3ee3b13f55d3e5ba2163b10e831357a9730c66a5e857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pyinfra 3.11.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.11.3 This release

2 release files No provenance

0.2.dev1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page