pyinfra-dev/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.

项目地址

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 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容