术语

Glossary

二进制分发
Binary Distribution

一种包含已编译扩展的特定类型的 Built Distribution (构建分发)。

A specific kind of Built Distribution that contains compiled extensions.

构建后端
Build Backend

一个库,它从源代码树构建 源分发构建分发。构建由 frontend 委托给后端。所有后端提供标准化的接口。

构建后端的示例包括: flit 的 flit-corehatch 的 hatchlingMaturinmeson-pythonscikit-build-core, 以及 Setuptools

A library that takes a source tree and builds a source distribution or built distribution from it. The build is delegated to the backend by a frontend. All backends offer a standardized interface.

Examples of build backends are flit's flit-core, hatch's hatchling, Maturin, meson-python, scikit-build-core, and Setuptools.

构建前端
Build Frontend

一个用户可能运行的工具,它接受任意的源代码树或 源分发,并从中构建源代码分发或 wheels。实际的构建工作委托给每个源代码树的 构建后端

构建前端的示例包括 pipbuild

A tool that users might run that takes arbitrary source trees or source distributions and builds source distributions or wheels from them. The actual building is delegated to each source tree's build backend.

Examples of build frontends are pip and build.

构建分发
Built Distribution

一种 分发 格式,包含文件和元数据,这些文件和元数据只需要被移动到目标系统上的正确位置即可安装。 Wheel 就是这样一种格式,而 源分发 则不是,因为它在安装之前需要一个构建步骤。该格式并不意味着 Python 文件必须是预编译的( Wheel 有意不包含已编译的 Python 文件)。有关更多信息,请参见 软件包格式

A Distribution format containing files and metadata that only need to be moved to the correct location on the target system, to be installed. Wheel is such a format, whereas Source Distribution is not, in that it requires a build step before it can be installed. This format does not imply that Python files have to be precompiled (Wheel intentionally does not include compiled Python files). See 软件包格式 for more information.

构建元数据
Built Metadata

当包含在已安装的 ProjectMETADATA 文件)或 Distribution Archive 中时, Core Metadata 的具体形式(在 Sdist 中为 PKG-INFO 文件,在 Wheel 中为 METADATA 文件)。

The concrete form Core Metadata takes when included inside an installed Project (METADATA file) or a Distribution Archive (PKG-INFO in a Sdist and METADATA in a Wheel).

核心元数据
Core Metadata

specification 及其定义的一组 核心元数据字段,用于描述 分发包已安装项目 的关键静态属性。

The specification and the set of Core Metadata Fields it defines that describe key static attributes of a Distribution Package or Installed Project.

核心元数据字段
Core Metadata Field

核心元数据 规范中定义的单个键值对(或者是具有相同名称的多个键值对,适用于多次使用的字段),并存储在 构建元数据 中。值得注意的是,它不同于 Pyproject Metadata Key

A single key-value pair (or sequence of such with the same name, for multiple-use fields) defined in the Core Metadata spec and stored in the Built Metadata. Notably, distinct from a Pyproject Metadata Key.

分发存档
Distribution Archive

分发包 的物理分发工件(即磁盘上的文件)。

The physical distribution artifact (i.e. a file on disk) for a Distribution Package.

分发包
Distribution Package

一个版本化的归档文件,其中包含用于分发 发布 的 Python 模块 和其他资源文件。该归档文件是最终用户从互联网下载并安装的文件。

分发包通常被简称为 “package” 或 “distribution” ,但本指南在需要更清晰区分时,会使用扩展术语,以防与 导入包 (也常被称为“package”)或其他类型的分发(例如 Linux 发行版或 Python 语言发行版)混淆。后者通常也被简称为“distribution”。有关这些差异的详细说明,请参见 分发包与导入包

A versioned archive file that contains Python packages, modules, and other resource files that are used to distribute a Release. The archive file is what an end-user will download from the internet and install.

A distribution package is more commonly referred to with the single words "package" or "distribution", but this guide may use the expanded term when more clarity is needed to prevent confusion with an Import Package (which is also commonly called a "package") or another kind of distribution (e.g. a Linux distribution or the Python language distribution), which are often referred to with the single term "distribution". See 分发包与导入包 for a breakdown of the differences.

Egg

Setuptools 引入的 构建分发 格式,已被 Wheel 取代。有关详细信息,请参见 那 eggs 呢?

A Built Distribution format introduced by Setuptools, which has been replaced by Wheel. For details, see 那 eggs 呢?.

扩展模块
Extension Module

一个用 Python 实现的底层语言编写的 Module : Python 使用 C/C++,Jython 使用 Java。通常包含在一个单独的动态加载的预编译文件中,例如:在 Unix 上用于 Python 扩展的共享对象文件(.so),在 Windows 上用于 Python 扩展的 DLL 文件(.pyd 扩展名),或用于 Jython 的 Java 类文件。

A Module written in the low-level language of the Python implementation: C/C++ for Python, Java for Jython. Typically contained in a single dynamically loadable pre-compiled file, e.g. a shared object (.so) file for Python extensions on Unix, a DLL (given the .pyd extension) for Python extensions on Windows, or a Java class file for Jython

extensions.

已知良好集 (KGS)
Known Good Set (KGS)

一组在指定版本下彼此兼容的分发包。通常会运行一个测试套件,确保所有测试通过,然后才会声明一组特定的包为已知的良好集合。这个术语通常用于由多个单独分发包组成的框架和工具包。

A set of distributions at specified versions which are compatible with each other. Typically a test suite will be run which passes all tests before a specific set of packages is declared a known good set. This term is commonly used by frameworks and toolkits which are comprised of multiple individual distributions.

导入包
Import Package

一个 Python 模块,可以包含其他模块或递归地包含其他包。

导入包通常简称为“包”,但本指南会在需要更多清晰度时使用扩展术语,以避免与 分发包 混淆,后者也常被称为“包”。有关两者区别的详细解释,请参见 分发包与导入包

A Python module which can contain other modules or recursively, other packages.

An import package is more commonly referred to with the single word "package", but this guide will use the expanded term when more clarity is needed to prevent confusion with a Distribution Package which is also commonly called a "package". See 分发包与导入包 for a breakdown of the differences.

已安装项目
Installed Project

一个 项目,已安装并用于 Python 解释器或 虚拟环境,如 记录已安装包 规范中所描述。

A Project that is installed for use with a Python interpreter or Virtual Environment, as described in the specicifcation 记录已安装的项目.

模块
Module

Python 中代码可重用性的基本单元,存在于以下两种类型之一:纯模块 (Pure Module) 或扩展模块 (Extension Module)。

The basic unit of code reusability in Python, existing in one of two types: Pure Module, or Extension Module.

包索引
Package Index

带有 Web 界面的分发存储库,用于自动化 的发现和使用。

A repository of distributions with a web interface to automate package discovery and consumption.

每个项目索引
Per Project Index

由特定:term:项目 指示的私有或其他非规范的 包索引 作为解决该项目依赖关系的首选索引或所需索引。

A private or other non-canonical Package Index indicated by a specific Project as the index preferred or required to resolve dependencies of that project.

项目
Project

一个库、框架、脚本、插件、应用程序或数据集或其他资源的集合,或这些元素的某种组合,旨在打包为一个 分发包

由于大多数项目使用 PEP 518build-systemdistutilsSetuptools 创建 分发包,因此另一种定义项目的实际方式是,它包含一个位于项目源代码目录根目录的 pyproject.tomlsetup.pysetup.cfg 文件。

Python 项目必须具有唯一的名称,这些名称在 PyPI 上注册。每个项目将包含一个或多个 发布,每个发布可能由一个或多个 分发包 组成。

请注意,有一个强烈的约定,即项目的名称与用于运行该项目的包的导入名称相同。然而,这个规则并非绝对成立。你可以从名为 'foo' 的项目安装分发包,并让它提供一个只能以 'bar' 作为包名导入的包。

A library, framework, script, plugin, application, or collection of data or other resources, or some combination thereof that is intended to be packaged into a Distribution.

Since most projects create Distributions using either PEP 518 build-system, distutils or Setuptools, another practical way to define projects currently is something that contains a pyproject.toml, setup.py, or setup.cfg file at the root of the project source directory.

Python projects must have unique names, which are registered on PyPI. Each project will then contain one or more Releases, and each release may comprise one or more distributions.

Note that there is a strong convention to name a project after the name of the package that is imported to run that project. However, this doesn't have to hold true. It's possible to install a distribution from the project 'foo' and have it provide a package importable only as 'bar'.

项目根目录
Project Root Directory

Project源树 所在的文件系统目录。

The filesystem directory in which a Project's source tree is located.

项目来源树
Project Source Tree

用于开发的 项目 的磁盘格式,包含其原始源代码,在被打包为 源分发包构建分发包 之前。

The on-disk format of a Project used for development, containing its raw source code before being packaged into a Source Distribution or Built Distribution.

项目源元数据
Project Source Metadata

由包作者在 项目源代码树 中定义的元数据,旨在通过项目的 构建后端 转换为 核心元数据字段,并包含在 构建元数据 中。

这些元数据可以写入为 Pyproject 元数据,或使用工具特定的格式(在 pyproject.toml 中的 [tool] 表格下,或在工具的配置文件中)。

Metadata defined by the package author in a Project's source tree, to be transformed into Core Metadata fields in the Built Metadata by the project's build backend. Can be written as Pyproject Metadata, or in a tool-specific format (under the [tool] table in pyproject.toml, or in a tool's own configuration file).

纯模块
Pure Module

用 Python 编写的 模块 包含在单个 .py 文件中(可能还有相关的 .pyc 和/或 .pyo 文件)。

A Module written in Python and contained in a single .py file (and possibly associated .pyc and/or .pyo files).

Pyproject 元数据
Pyproject Metadata

pyproject.toml 规范 规范定义的 项目源元数据 格式,最初在 PEP 621 中引入,存储为 Pyproject 元数据键,位于 pyproject.toml 文件的 [project] 表格下。

值得注意的是,这 不是pyproject.toml 文件的 [tool] 表格下的工具特定源元数据格式。

The Project Source Metadata format defined by the pyproject.toml 规范 specification and originally introduced in PEP 621, stored as Pyproject Metadata Keys under the [project] table of a pyproject.toml file. Notably, not a tool-specific source metadata format under the [tool] table in pyproject.toml.

Pyproject 元数据键
Pyproject Metadata Key

pyproject.toml 文件中 [project] 表格的顶级 TOML 键;是 Pyproject 元数据 的一部分。值得注意的是,它不同于 核心元数据字段

A top-level TOML key in the [project] table in pyproject.toml; part of the Pyproject Metadata. Notably, distinct from a Core Metadata Field.

Pyproject 元数据子键
Pyproject Metadata Subkey

在一个表值型 Pyproject 元数据键 下的第二级 TOML 键。

A second-level TOML key under a table-valued Pyproject Metadata Key.

Python 打包权威机构 (PyPA)
Python Packaging Authority (PyPA)

PyPA 是一个工作组,负责维护许多与 Python 打包相关的项目。他们维护一个网站:pypa.io,并在 GitHubBitbucket 上托管项目,讨论问题的邮件列表是 distutils-sig mailing list,此外还在 Python Discourse 论坛 上讨论。

PyPA is a working group that maintains many of the relevant projects in Python packaging. They maintain a site at pypa.io, host projects on GitHub and Bitbucket, and discuss issues on the distutils-sig mailing list and the Python Discourse forum.

Python 软件包索引 (PyPI)
Python Package Index (PyPI)

PyPI 是 Python 社区的默认 包索引。它对所有 Python 开发者开放,用于消费和分发他们的发行版。

PyPI is the default Package Index for the Python community. It is open to all Python developers to consume and distribute their distributions.

pypi.org

pypi.orgPython 包索引 (PyPI) 的域名。它于 2017 年取代了旧的索引域名 pypi.python.org。该站点由 Warehouse 提供支持。

pypi.org is the domain name for the Python Package Index (PyPI). It replaced the legacy index domain name, pypi.python.org, in 2017. It is powered by Warehouse.

pyproject.toml

工具无关的 项目 规范文件,定义于 PEP 518 中。

The tool-agnostic Project specification file. Defined in PEP 518.

发布
Release

在特定时间点的 项目 快照,通过版本标识符表示。

发布一个版本可能涉及多个 发行包 的发布。例如,如果某个项目的 1.0 版本被发布,它可能同时以源代码发行包格式和 Windows 安装程序发行包格式提供。

A snapshot of a Project at a particular point in time, denoted by a version identifier.

Making a release may entail the publishing of multiple Distributions. For example, if version 1.0 of a project was released, it could be available in both a source distribution format and a Windows installer distribution format.

需求
Requirement

用于安装的 规范。 pip,即 PYPA 推荐的安装工具,支持多种形式的规范,这些都可以被视为“需求”。更多信息,请参见 pip install 参考文档。

A specification for a package to be installed. pip, the PYPA recommended installer, allows various forms of specification that can all be considered a "requirement". For more information, see the pip install reference.

需求说明
Requirement Specifier

一种由 pip 用于从 Package Index 安装包的格式。有关该格式的 EBNF 图示,请参见 依赖说明符。例如,"foo>=1.3" 是一个需求规范符,其中 "foo" 是项目名称,">=1.3" 部分是 Version Specifier (版本规范符)。

A format used by pip to install packages from a Package Index. For an EBNF diagram of the format, see 依赖说明符. For example, "foo>=1.3" is a requirement specifier, where "foo" is the project name, and the ">=1.3" portion is the Version Specifier

需求文件
Requirements File

一个包含可以使用 pip 安装的 Requirements 列表的文件。有关更多信息,请参阅 pip 文档中的 Requirements Files 部分。

A file containing a list of Requirements that can be installed using pip. For more information, see the pip docs on Requirements Files.

setup.py
setup.cfg

这是 distutilsSetuptools 的项目规范文件。另请参见 pyproject.toml

The project specification files for distutils and Setuptools. See also pyproject.toml.

源存档
Source Archive

一个包含 发布 原始源代码的档案,在创建 源分发包构建分发包 之前。

An archive containing the raw source code for a Release, prior to creation of a Source Distribution or Built Distribution.

源分发
Source Distribution (or "sdist")

一种 分发包 格式(通常通过 python -m build --sdist 生成),提供元数据和安装所需的基本源文件,可以被像 pip 这样的工具用于安装,或用于生成 构建分发包。有关更多信息,请参见 软件包格式

A distribution format (usually generated using python -m build --sdist) that provides metadata and the essential source files needed for installing by a tool like pip, or for generating a Built Distribution. See 软件包格式 for more information.

系统包
System Package

以操作系统原生格式提供的包,例如 rpm 或 dpkg 文件。

A package provided in a format native to the operating system, e.g. an rpm or dpkg file.

版本说明
Version Specifier

版本组件,属于 Requirement Specifier 的一部分。例如,"foo>=1.3" 中的 ">=1.3" 部分。有关当前 Python 包管理支持的版本说明符的完整描述,请阅读 Version specifier specification。此规范的支持已在 Setuptools v8.0 和 pip v6.0 中实现。

The version component of a Requirement Specifier. For example, the ">=1.3" portion of "foo>=1.3". Read the Version specifier specification for a full description of the specifiers that Python packaging currently supports. Support for this specification was implemented in Setuptools v8.0 and pip v6.0.

虚拟环境
Virtual Environment

一个隔离的 Python 环境,允许为特定应用程序安装包,而不是将其系统范围内安装。有关更多信息,请参见 创建和使用虚拟环境 部分。

An isolated Python environment that allows packages to be installed for use by a particular application, rather than being installed system wide. For more information, see the section on 创建虚拟环境.

Wheel Format
Wheel

最初在 PEP 427 中引入并由 二进制分发格式 规范定义的标准 Built Distribution 格式。有关更多信息,请参见 软件包格式。不要与其参考实现 Wheel Project 混淆。

The standard Built Distribution format originally introduced in PEP 427 and defined by the 二进制分发格式 specification. See 软件包格式 for more information. Not to be confused with its reference implementation, the Wheel Project.

Wheel 项目
Wheel Project

PyPA 对 Wheel Format 的参考实现;参见 wheel

The PyPA reference implementation of the Wheel Format; see wheel.

工作集
Working Set

一组可供导入的 distributions。这些是位于 sys.path 变量中的分发包。在一个工作集(working set)中,最多只能有一个项目的 Distribution

A collection of distributions available for importing. These are the distributions that are on the sys.path variable. At most, one Distribution for a project is possible in a working set.