部署 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 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 是一个基于NSIS的单一安装程序,并将 Python 程序与 Python 解释器捆绑在一起的工具。在大多数情况下,打包 (packaging) 只需要用户选择 Python 解释器的版本并声明程序的依赖性 (dependencies) 。该工具会下载用于 Windows 的 Python 解释器,并将其与所有依赖项打包成一个可在 Windows 执行的安装程序。

安装的程序可以从安装程序添加到开始菜单的快捷方式启动。它使用一个安装在其应用程序目录中的Python解释器,与计算机上的任何其他 Python 安装无关。

A big advantage of Pynsist is that the Windows packages can be built on Linux. There are several examples for different kinds of programs (console, GUI) in the documentation. The tool is released under the MIT-licence.

应用捆绑

FIXME

- wheels kinda/sorta

Windows 系统

py2exe

py2exe is a distutils extension which allows to build standalone Windows executable programs (32-bit and 64-bit) from Python scripts. Python versions included in the official development cycle are supported (refers to Status of Python branches). py2exe can build console executables and windows (GUI) executables. Building windows services, and DLL/EXE COM servers might work but it is not actively supported. The distutils extension is released under the MIT-licence and Mozilla Public License 2.0.

macOS

py2app

py2app is a Python setuptools command which will allow you to make standalone macOS application bundles and plugins from Python scripts. Note that py2app MUST be used on macOS to build applications, it cannot create Mac applications on other platforms. py2app is released under the MIT-license.

Unix (including Linux and macOS)

pex

pex is a library for generating .pex (Python EXecutable) files which are executable Python environments in the spirit of virtualenvs. pex is an expansion upon the ideas outlined in PEP 441 and makes the deployment of Python applications as simple as cp. pex files may even include multiple platform-specific Python distributions, meaning that a single pex file can be portable across Linux and macOS. pex is released under the Apache License 2.0.

配置管理

FIXME

puppet
salt
chef
ansible
fabric