This PEP specifies how to write a project’s external, or non-PyPI, build and runtime dependencies in a pyproject.toml file for packaging-related tools to consume.
This PEP proposes to add an [external] table to pyproject.toml with seven keys. “build-requires”, “host-requires” and “dependencies” are for specifying three types of required dependencies:
These three keys also have their optional external counterparts (optional-build-requires, optional-host-requires, optional-dependencies), which have the same role that project.optional-dependencies plays for project.dependencies. Finally, dependency-groups offers the same functionality as PEP 735 but for external dependencies.
Cross compilation is taken into account by distinguishing between build and host dependencies. Optional build-time and runtime dependencies are supported too, in a manner analogous to how that is supported in the [project] table.
Python packages may have dependencies on build tools, libraries, command-line tools, or other software that is not present on PyPI. Currently there is no way to express those dependencies in standardized metadata [1], [2]. Key motivators for this PEP are to:
Packaging ecosystems like Linux distros, conda, Homebrew, Spack, and Nix need full sets of dependencies for Python packages, and have tools like pyp2spec (Fedora), Grayskull (conda), and dh_python (Debian) which attempt to automatically generate dependency metadata for their own package managers from the metadata in upstream Python packages. External dependencies are currently handled manually, because there is no metadata for this in pyproject.toml or any other standard location. Other tools resort to extracting dependencies from extension modules and shared libraries inside Python packages, like elfdeps (Fedora). Enabling automating this type of conversion by only using explicitly annotated metadata is a key benefit of this PEP, making packaging Python packages for distros easier and more reliable. In addition, the authors envision other types of tools making use of this information, e.g., dependency analysis tools like Repology, Dependabot and libraries.io.
Software bill of materials (SBOM) generation tools may also be able to use this information, e.g. for flagging that external dependencies listed in pyproject.toml but not contained in wheel metadata are likely vendored within the wheel. PEP 770, which standardizes how SBOMs are included in wheels, contains an instructive section on how that PEP differs from this one.
Packages with external dependencies are typically hard to build from source, and error messages from build failures tend to be hard to decipher for end users. Missing external dependencies on the end user’s system are the most likely cause of build failures. If installers can show the required external dependencies as part of their error message, this may save users a lot of time.
At the moment, information on external dependencies is only captured in installation documentation of individual packages. It is hard to maintain for package authors and tends to go out of date. It’s also hard for users and distro packagers to find it. Having a canonical place to record this dependency information will improve this situation.
This PEP is not trying to specify how the external dependencies should be used, nor a mechanism to implement a name mapping from names of individual packages that are canonical for Python projects published on PyPI to those of other packaging ecosystems. Canonical names and a name mapping mechanism are addressed in PEP 804.
Multiple types of external dependencies can be distinguished:
Concrete packages are straightforward to understand, and are a concept present in every package management system. Virtual packages are a concept also present in a number of packaging systems – but not always, and the details of their implementation vary.
Cross compilation is not yet (as of September 2025) well-supported by stdlib modules and pyproject.toml metadata. It is however important when translating external dependencies to those of other packaging systems (with tools like pyp2spec). Introducing support for cross compilation immediately in this PEP is much easier than extending [external] in the future, hence the authors choose to include this now.
This PEP uses the following terminology:
Note that this terminology is not consistent across build and packaging tools, so care must be taken when comparing build/host dependencies in pyproject.toml to dependencies from other package managers.
Note that “target machine” or “target dependency” are not used in this PEP. That is typically only relevant for cross-compiling a compiler or other such advanced scenarios [3], [4] – this is out of scope for this PEP.
Finally, note that while “dependency” is the term most widely used for packages needed at build time, the existing key in pyproject.toml for PyPI build-time dependencies is build-requires. Hence this PEP uses the keys build-requires and host-requires under [external] for consistency.
Clear separation of metadata associated with the definition of build and host platforms, rather than assuming that build and host platform will always be the same, is important [5].
Build dependencies are typically run during the build process - they may be compilers, code generators, or other such tools. In case the use of a build dependency implies a runtime dependency, that runtime dependency does not have to be declared explicitly. For example, when compiling Fortran code with gfortran into a Python extension module, the package likely incurs a dependency on the libgfortran runtime library. The rationale for not explicitly listing such runtime dependencies is two-fold: (1) it may depend on compiler/linker flags or details of the build environment whether the dependency is present, and (2) these runtime dependencies can be detected and handled automatically by tools like auditwheel.
Host dependencies are typically not run during the build process, but only used for linking against. This is not a rule though – it may be possible or necessary to run a host dependency under an emulator, or through a custom tool like crossenv. When host dependencies imply a runtime dependency, that runtime dependency also does not have to be declared, just like for build dependencies.
When host dependencies are declared and a tool which is executing an action unrelated to cross-compiling, it may decide to merge the host-requires list into build-requires - whether this is useful is context-dependent.
A “Package URL” or PURL is a widely used URL string for identifying packages that is meant to be portable across packaging ecosystems. Its design is:
The scheme component is a fixed string, pkg, and of the other components only type and name are required.
Since external dependencies are likely to be typed by hand, we propose a PURL derivative that, in the name of ergonomics and user-friendliness, introduces a number of changes (further discussed below):
In this derivative, we replace the pkg scheme with dep. Hence, we will refer to them as DepURLs.
As an example, a DepURL for the requests package on PyPI would be:
Adopting PURL-compatible strings to specify external dependencies in pyproject.toml solves a number of problems at once, and there are already implementations of the specification in Python and multiple other languages. PURL is also already supported by dependency-related tooling like SPDX (see External Repository Identifiers in the SPDX 2.3 spec), the Open Source Vulnerability format, and the Sonatype OSS Index; not having to wait years before support in such tooling arrives is valuable. DepURLs are very easily transformed into PURLs, with the exception of dep:virtual which doesn’t have an equivalent in PURL.
For concrete packages without a canonical package manager to refer to, either dep:generic/dep-name can be used, or a direct reference to the VCS system that the package is maintained in (e.g., dep:github/user-or-org-name/dep-name). Which of these is more appropriate is situation-dependent. This PEP recommends using dep:generic when the package name is unambiguous and well-known (e.g., dep:generic/git or dep:generic/openblas), and using the VCS as the type otherwise. Which name is chosen as canonical for any given package, as well as the process to make and record such choices, is the topic of PEP 804.
PURL does not offer support for virtual or virtual dependency specification yet. A proposal to add a virtual type is being discussed for revision 1.1.
In the meantime, we propose adding a new type to our dep: derivative, the virtual type, which can take two namespaces (extensible through the process given in PEP 804):
The name should be the most common name for the interface or language, lowercased. Some examples include:
Since there are a limited number of such dependencies, it seems like it will be understandable and map well to Linux distros with virtual packages and to the likes of conda and Spack.
PURLs support fixed versions via the @ component of the URL. For example, numpy===2.0 can be expressed as pkg:pypi/numpy@2.0.
Support in PURL for version expressions and ranges beyond a fixed version is available via vers URIs (see specification):
Users are supposed to couple a pkg: URL with a vers: URL. For example, to express numpy>=2.0, the PURL equivalent would be pkg:pypi/numpy plus vers:pypi/>=2.0. This can be done with:
Since none of these options are very ergonomic, we chose instead for DepURLs to accept version range specifiers too with semantics that are a subset of PEP 440 semantics. The allowed operators are those that are widely available across package managers (e.g., ==, > and >= are common, while ~= isn’t).
Some examples:
The versioning scheme for particular virtual packages, in case that isn’t unambiguously defined by an upstream project or standard, will be defined in the Central Registry (see PEP 804).
Regular environment markers (as originally defined in PEP 508) may be used behind DepURLs. PURL qualifiers, which use ? followed by a package type-specific dependency specifier component, should not be used for the purposes for which environment markers suffice. The reason for this is pragmatic: environment markers are already used for other metadata in pyproject.toml, hence any tooling that is used with pyproject.toml is likely to already have a robust implementation to parse it. And we do not expect to need the extra possibilities that PURL qualifiers provide (e.g., to specify a Conan or conda channel, or a RubyGems platform).
We name the combination of a DepURL and environment markers as “external dependency specifiers”, analogously to the existing dependency specifiers.
It is fairly common, but far from universal, for distros to split a package into two or more packages. In particular, runtime components are often separately installable from development components (headers, pkg-config and CMake files, etc.). The latter then typically has a name with -dev or -devel appended to the project/library name. Also, larger packages are sometimes split into multiple separate packages to keep install sizes manageable. More often than not, such package splits are not defined or recognized by the maintainers of a package, and it’s therefore ambiguous what any split would mean. Hence, such splits should not be reflected in the [external] table. It is not possible to specify this in a reasonable way that works across distros, hence only the canonical name should be used in [external].
The intended meaning of using a DepURL is “the full package with the name specified”. I.e., including all installable artifacts that are part of the package. It will depend on the context in which the metadata is used whether a package split is relevant. For example, if libffi is a host dependency and a tool wants to prepare an environment for building a wheel, then if a distro has split off the headers for libffi into a libffi-devel package then the tool has to install both libffi and libffi-devel.
For defining what canonical package names are and how package splits are handled in practice when tools attempt to use [external] for installation purposes, we refer to PEP 804.
Python headers and other build support files may also be split. This is the same situation as in the section above (because Python is simply a regular package in distros). However, a python-dev|devel dependency is special because in pyproject.toml Python itself is an implicit rather than an explicit dependency. Hence a choice needs to be made here - add python-dev implicitly, or make each package author add it explicitly under [external]. For consistency between Python dependencies and external dependencies, we choose to add it implicitly. Python development headers must be assumed to be necessary when an [external] table contains one or more compiler packages.
Two new Core Metadata fields are proposed:
Since the Core Metadata specification does not contain fields for any metadata in pyproject.toml’s [build-system] table, the build-requires and host-requires content do not need to be reflected in existing core metadata fields.
Additionally, this PEP also proposes to deprecate the Requires-External field. The reasons being:
A wheel may vendor its external dependencies. This happens in particular when distributing wheels on PyPI or other Python package indexes – and tools like auditwheel, delvewheel and delocate automate this process. As a result, a Requires-External-Dep entry in an sdist may disappear from a wheel built from that sdist with a tool like cibuildwheel. It is also possible that a Requires-External-Dep entry remains in a wheel, either unchanged or with narrower constraints. auditwheel does not vendor certain allow-listed dependencies, such as OpenGL, by default. In addition, auditwheel and delvewheel allow a user to manually exclude dependencies via a --exclude or --no-dll command-line flag. This is used to avoid vendoring large shared libraries, for example those from CUDA.
Requires-External-Dep entries generated from external dependencies in pyproject.toml can therefore differ between an sdist and its corresponding wheel(s) depending on the build/distribution process.
Note that this does not imply that the field must be marked as Dynamic, since this distinction only applies to wheels built from an sdist by a build backend. In particular, wheels built from other wheels do not need to satisfy this constraint.
This PEP has chosen to include the PEP 735 key dependency-groups under the [external] table too. This decision is motivated by the need of having similar functionality for external metadata. The top-level table cannot be used for external dependencies because it’s expected to have PEP 508 strings (and tables for group includes), while we have chosen to rely on dep: URLs for the external dependencies. Conflating both would raise significant backwards compatibility issues with existing usage.
Strictly speaking, the dependency-groups schema allows us to define external dependencies in per-group sub-tables:
However, this has the same problem: we are mixing different types of dependency specifiers in the same data structure. We believe it’s cleaner to separate concerns in different top-level tables, hence why we still prefer to have external.dependency-groups.
The rationale for having external.dependency-groups is identical for the rationale given in PEP 735 for introducing [dependency-groups]. The intended usage and semantics of inclusion/exclusion into Core Metadata is thus identical to [dependency-groups].
external.optional-dependencies will show up in Core Metadata. external.dependency-groups will not.
If metadata is improperly specified then tools MUST raise an error to notify the user about their mistake.
A DepURL implements a scheme for identifying packages that is meant to be portable across packaging ecosystems. Its design is:
dep: is a fixed string, and always present. type and name are required, other components are optional. All components apply for both PURL and virtual type’s, and have these requirements:
External dependency specifiers MUST contain a DepURL, and MAY contain environment markers with the same syntax as used in regular dependency specifiers (as originally specified in PEP 508).
The External-Requires Core Metadata field will be marked as obsolete and its usage will be discouraged.
Two new fields are added to Core Metadata:
Given that the proposed changes are purely additive, the Core Metadata version will be bumped to 2.6.
This will only impact PyPI and tools that want to support external runtime dependencies, and require no changes otherwise.
Note that pyproject.toml content is in the same format as in PEP 621.
Tools MUST specify fields defined by this PEP in a table named [external]. No tools may add fields to this table which are not defined by this PEP or subsequent PEPs. The lack of an [external] table means the package either does not have any external dependencies, or the ones it does have are assumed to be present on the system already.
The (optional) external build requirements needed to build the project.
For build-requires, it is a key whose value is an array of strings. Each string represents a build requirement of the project and MUST be formatted as a valid external dependency specifier.
For optional-build-requires, it is a table where each key specifies an extra set of build requirements and whose value is an array of strings. The strings of the arrays MUST be valid external dependency specifiers.
The (optional) external host requirements needed to build the project.
For host-requires, it is a key whose value is an array of strings. Each string represents a host requirement of the project and MUST be formatted as a valid external dependency specifier.
For optional-host-requires, it is a table where each key specifies an extra set of host requirements and whose value is an array of strings. The strings of the arrays MUST be valid external dependency specifiers.
The (optional) runtime dependencies of the project.
For dependencies, it is a key whose value is an array of strings. Each string represents a dependency of the project and MUST be formatted as a valid external dependency specifier. Each string must be added to Core Metadata as a Requires-External-Dep field.
For optional-dependencies, it is a table where each key specifies an extra and whose value is an array of strings. The strings of the arrays MUST be valid external dependency specifiers. For each optional-dependencies group:
PEP 735 -style dependency groups, but using external dependency specifiers instead of PEP 508 strings. Every other detail (e.g. group inclusion, name normalization) follows the official dependency groups specification.
These examples show what the [external] table content for a number of packages, and the corresponding PKG-INFO/METADATA content (if any) is expected to be.
pyproject.toml content:
PKG-INFO / METADATA content: N/A.
pyproject.toml content:
PKG-INFO / METADATA content: N/A.
pyproject.toml content:
PKG-INFO / METADATA content: N/A.
pyproject.toml content:
PKG-INFO / METADATA content:
pyproject.toml content:
PKG-INFO / METADATA content:
pyproject.toml content:
PKG-INFO / METADATA content:
pyproject.toml content:
PKG-INFO / METADATA content:
pyproject.toml content:
PKG-INFO / METADATA content: N/A.
There is no impact on backwards compatibility, as this PEP only adds new, optional metadata. In the absence of such metadata, nothing changes for package authors or packaging tooling.
The only change introduced in this PEP that has impact on existing projects is the deprecation of the External-Requires Core Metadata field. We estimate the impact of this deprecation to be negligible, given the its low penetration in the ecosystem (see Rationale).
The field will still be recognized by existing tools such as setuptools-ext but its usage will be discouraged in the Python Packaging User Guide, similar to what is done for obsolete fields like Requires (deprecated in favor of Requires-Dist).
There are no direct security concerns as this PEP covers how to statically define metadata for external dependencies. Any security issues would stem from how tools consume the metadata and choose to act upon it.
External dependencies and if and how those external dependencies are vendored are topics that are typically not understood in detail by Python package authors. We intend to start from how an external dependency is defined, the different ways it can be depended on—from runtime-only with ctypes or a subprocess call to it being a build dependency that’s linked against— before going into how to declare external dependencies in metadata. The documentation should make explicit what is relevant for package authors, and what for distro packagers.
Material on this topic will be added to the most relevant packaging tutorials, primarily the Python Packaging User Guide. In addition, we expect that any build backend that adds support for external dependencies metadata will include information about that in its documentation, as will tools like auditwheel.
This PEP contains a metadata specification, rather that a code feature - hence there will not be code implementing the metadata spec as a whole. However, there are parts that do have a reference implementation:
There are multiple possible consumers and use cases of this metadata, once that metadata gets added to Python packages. Tested metadata for all of the top 150 most-downloaded packages from PyPI with published platform-specific wheels can be found in rgommers/external-deps-build. This metadata has been validated by using it to build wheels from sdists patched with that metadata in clean Docker containers.
Given a pyproject.toml with this [external] table:
You can use pyproject_external.External to parse it and manipulate it:
Note the proposed [external] table was well-formed. With invalid contents such as:
You would fail the validation:
There are non-Python packages which are packaged on PyPI, such as Ninja, patchelf and CMake. What is typically desired is to use the system version of those, and if it’s not present on the system then install the PyPI package for it. The authors believe that specific support for this scenario is not necessary (or at least, too complex to justify such support); a dependency provider for external dependencies can treat PyPI as one possible source for obtaining the package. An example mapping for this use case is proposed in PEP 804.
A previous draft PEP (“External dependencies” (2015)) proposed using specific library and header names as external dependencies. This is both too granular, and insufficient (e.g., headers are often unversioned; multiple packages may provide the same header or library). Using package names is a well-established pattern across packaging ecosystems and should be preferred.
This convention is not consistent across packaging ecosystems, nor commonly accepted by upstream package authors. Since the need for explicit control (e.g., installing headers when a package is used as a runtime rather than a build-time dependency) is quite niche and we don’t want to add design complexity without enough clear use cases, we have chosen to rely solely on the build, host and run category split, with tools being in charge of which category applies to each case in a context-dependent way.
If this proves to be insufficient, a future PEP could use the URL qualifier features present in the PURL schema (?key=value) to implement the necessary adjustments. This can be done in a backwards compatible fashion.
Some ecosystems exhibit methods to select packages based on parametrized functions like cmake("dependency") or compiler("language"), which return package names based on some additional context or configuration. This feature is arguably not very common and, even when present, rarely used. Additionally, its dynamic nature makes it prone to changing meaning over time, and relying on specific build systems for the name resolution is in general not a good idea.
The authors prefer static identifiers that can be mapped explicitly via well known metadata (e.g., as proposed in PEP 804).
Ecosystems that do implement these indirections can use them to support the infrastructure designed to generate the mappings proposed in PEP 804.
Adding host-requires for host dependencies that are on PyPI in order to better support name mapping to other packaging systems with support for cross-compiling seems useful in principle, for the same reasons as this PEP adds a host-requires under the [external] table. However, it isn’t necessary to include in this PEP, and hence the authors prefer to keep the scope of this PEP limited - a future PEP on cross compilation may want to tackle this. This issue contains more arguments in favor and against adding host-requires under [build-system] as part of this PEP.
The Core Metadata specification contains one relevant field, namely Requires-External. While at first sight it would be a good candidate to record the external.dependencies table, the authors have decided to not re-use this field to propagate the external runtime dependencies metadata.
The Requires-External field has very loosely defined semantics as of version 2.4. Essentially: name [(version)][; environment marker] (with square brackets denoting optional fields). It is not defined what valid strings for name are; the example in the specification uses both “C” as a language name, and “libpng” as a package name. Tightening up the semantics would be backwards incompatible, and leaving it as is seems unsatisfactory. DepURLs would need to be decomposed to fit in this syntax.
There are cases, in particular when dealing with pre-releases, where PEP 440 semantics for version comparisons don’t quite work. For example, 1.2.3a may indicate a release subsequent to 1.2.3 rather than an alpha version. To handle such cases correctly, it would be necessary to allow arbitrary versioning schemes. The authors of this PEP consider the added value of allowing that is not justified by the additional complexity. If desired, a package author can use either a code comment or the qualifier field of a DepURL (see the Versioning section under Rationale) to capture this level of detail.
None at this time.
This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive.
Source: https://github.com/python/peps/blob/main/peps/pep-0725.rst
Last modified: 2026-04-17 20:50:48 UTC