高性能基础设施管理工具pyinfra

项目概述

pyinfra 是一个高性能的基础设施管理工具,它将 Python 代码转换为 shell 命令,并能够在服务器上执行。这使得用户可以快速执行临时命令或编写声明式操作,支持 SSH 服务器、本地机器和 Docker 容器,适用于从单台服务器到成千上万台的规模。

项目地址

https://github.com/pyinfra-dev/pyinfra

项目页面预览

pyinfra-dev/pyinfra preview

关键指标

  • Stars:4641
  • 主要语言:Python
  • License:MIT License
  • 最近更新:2026-01-05T09:58:02Z
  • 默认分支:3.x

本站高速下载(国内可用)

点击下载(本站镜像)
– SHA256:b3bfd1a6d1eb62f0fece459a0c516f1892bdea7b4efcb2272d68c4d436c358d1

安装部署要点(README 精选)

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

常用命令(从 README 提取)

uv tool install pyinfra

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

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

通用部署说明

  1. 下载源码并阅读 README
  2. 安装依赖(pip/npm/yarn 等)
  3. 配置环境变量(API Key、模型路径、数据库等)
  4. 启动服务并测试访问
  5. 上线建议:Nginx 反代 + HTTPS + 进程守护(systemd / pm2)

免责声明与版权说明

本文仅做开源项目整理与教程索引,源码版权归原作者所有,请遵循对应 License 合规使用。

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容