部署 Python 应用程序¶
- 页面状态:
未完成
- 上次审核时间:
2021-8-24
概述¶
支持多种硬件平台¶
FIXME
Meaning: x86, x64, ARM, others?
For Python-only distributions, it *should* be straightforward to deploy on all
platforms where Python can run.
For distributions with binary extensions, deployment is a major headache. Not only
must the extensions be built on all the combinations of operating system and
hardware platform, but they must also be tested, preferably on continuous
integration platforms. The issues are similar to the "multiple Python
versions" section above, not sure whether this should be a separate section.
Even on Windows x64, both the 32 bit and 64 bit versions of Python enjoy
significant usage.
操作系统打包和安装程序¶
FIXME
- Building rpm/debs for projects
- Building rpms/debs for whole virtualenvs
- Building macOS installers for Python projects
- Building Android APKs with Kivy+P4A or P4A & Buildozer
Windows¶
FIXME
- Building Windows installers for Python projects
Pynsist¶
Pynsist 是一个工具,它将 Python 程序和 Python 解释器捆绑到一个基于 NSIS 的安装程序中。在大多数情况下,打包只需用户选择一个 Python 解释器版本并声明程序的依赖项。该工具会下载指定的 Windows Python 解释器,并将其与所有依赖项一起打包到一个单独的 Windows 可执行安装程序中。
安装的程序可以通过安装程序添加到开始菜单的快捷方式启动。它使用安装在应用程序目录中的 Python 解释器,独立于计算机上任何其他 Python 安装。
Pynsist 的一个巨大优势是 Windows 包可以在 Linux 上构建。文档 中有几种不同类型程序(控制台、GUI)的示例。该工具根据 MIT 许可证发布。
应用程序包¶
FIXME
- wheels kinda/sorta
Windows¶
py2exe¶
py2exe 是一个 distutils 扩展,允许从 Python 脚本构建独立的 Windows 可执行程序(32 位和 64 位)。官方开发周期中包含的 Python 版本都受支持(参见 Python 分支状态)。py2exe 可以构建控制台可执行文件和 Windows (GUI) 可执行文件。构建 Windows 服务以及 DLL/EXE COM 服务器可能有效,但不受积极支持。该 distutils 扩展根据 MIT 许可证和 Mozilla Public License 2.0 发布。
macOS¶
py2app¶
py2app 是一个 Python setuptools 命令,它允许您从 Python 脚本制作独立的 macOS 应用程序包和插件。请注意,py2app 必须在 macOS 上使用才能构建应用程序,它无法在其他平台上创建 Mac 应用程序。py2app 根据 MIT 许可证发布。
Unix(包括 Linux 和 macOS)¶
pex¶
pex 是一个用于生成 .pex(Python 可执行)文件的库,这些文件是类似 virtualenvs 的可执行 Python 环境。pex 是 PEP 441 中概述的理念的扩展,使 Python 应用程序的部署像 cp 一样简单。pex 文件甚至可以包含多个特定于平台的 Python 分发版,这意味着单个 pex 文件可以在 Linux 和 macOS 上移植。pex 根据 Apache License 2.0 发布。
配置管理¶
FIXME
puppet
salt
chef
ansible
fabric