PEP 739 – Static description file for build details of Python installations
- Author:
- Filipe Laíns <lains at riseup.net>
- PEP-Delegate:
- Paul Moore <p.f.moore at gmail.com>
- Discussions-To:
- Discourse thread
- Status:
- Draft
- Type:
- Standards Track
- Topic:
- Packaging
- Created:
- 19-Dec-2023
- Python-Version:
- 3.14
Abstract
Introduce a standard format for a static description file with build details of Python installations.
Rationale
When introspecting a Python installation, running code is often undesirable or impossible. Having a static description file makes various of Python build details available without having to run the interpreter.
This is helpful for use-cases such as cross-compilation, Python launchers, etc.
Scope
This PEP defines a format for the description file, and a standard location for where to place it.
Location
When possible, Python installations should install the static description file
inside the standard library directory, with the name build-details.json
(Eg. /usr/lib/python3.14/build-details.json
).
Important
Given that there may be technical challenges, Python implementations are not required to provide the file if not feasable. In such scenarios, they may choose to provide it in a different maner.
Attention
Notwithstanding the standard location specified here, it does not prevent the file from additionally being provided in another location, and with a different name. In fact, the PEP authors expect future PEPs to define additional locations to install this file, for better discoverability.
Format
The format specification is defined by the JSON Schema definition provided below, which is rendered in an human-readable format here.
$schema |
https://json-schema.org/draft/2020-12/schema |
$id |
https://github.com/python/peps/blob/main/peps/pep-0739/python-build-info-v1.0.schema.json |
Title | Static description file for the build details of Python installations |
Type | object |
Additional properties | Not allowed |
schema_version
Type | string (constant — 1.0 ) |
Description | Schema version. This is a string following the format For this specification version, this value is constant and MUST
be Future versions of this schema MUST use a higher version number.
Future versions of this schema MUST NOT use the same major
version component as other schema version unless its
specification is deemed backwards-compatible with them — it
can’t change, or extend, any parts of the current specification
in such a way as the semantics of the interpreted data differ,
or that data valid under the new specification is invalid under
the older specification, with the exception of additional
properties (errors caused by |
Required | True |
base_prefix
Type | string |
Description | Base prefix of the Python installation. Either an absolute path, or a relative path to directory where this file is contained. |
Examples | /usr , ../.. , etc. |
Required | False |
platform
Type | string |
Description | System platform string. This field SHOULD be equivalent to |
Examples |
|
Required | True |
language
Type | object |
Description | Object containing details related to the Python language
specification. In addition to the required keys, implementations may choose to include extra keys with implementation-specific details. |
Required | True |
Additional properties | Not allowed |
language.version
Type | string |
Description | String representation the Python language version — a version
string consisting only of the major and minor components. This field SHOULD be equivalent to
|
Examples | 3.14 , etc. |
Required | True |
language.version_info
Type | object |
Description | Object in the format of sys.version_info .This section SHOULD be equivalent to
|
Examples |
|
Required | False |
Additional properties | Not allowed |
language.version_info.major
Type | number |
Required | True |
language.version_info.minor
Type | number |
Required | True |
language.version_info.micro
Type | number |
Required | True |
language.version_info.releaselevel
Type | string (enum — alpha , beta , candidate , final ) |
Required | True |
language.version_info.serial
Type | number |
Required | True |
implementation
Type | object |
Description | Object containing details related to Python implementation. This section SHOULD be equivalent to
|
Required | True |
Additional properties | Allowed |
implementation.name
Type | string |
Description | Lower-case name of the Python implementation. |
Examples | cpython , pypy , etc. |
Required | True |
implementation.version
Type | object |
Description | Object in the format of sys.version_info , containing
the implementation version. |
Examples |
|
Required | True |
Additional properties | Not allowed |
implementation.version.major
Type | number |
Required | True |
implementation.version.minor
Type | number |
Required | True |
implementation.version.micro
Type | number |
Required | True |
implementation.version.releaselevel
Type | string (enum — alpha , beta , candidate , final ) |
Required | True |
implementation.version.serial
Type | number |
Required | True |
interpreter
Type | object |
Description | Object containing details Python interpreter. This section MUST be present if the Python installation provides an interpreter binary, otherwise this section will be missing. |
Required | False |
Additional properties | Not allowed |
interpreter.path
Type | string |
Description | The path to the Python interprer. Either an absolute path, or a
relative path to the path defined in the base_prefix key. |
Examples |
|
Required | True |
abi
Type | object |
Description | Object containing details related to ABI. |
Required | False |
Additional properties | Not allowed |
abi.flags
Type | array |
Description | Build configuration flags, used to calculate the extension
suffix. The flags MUST be defined in the order they appear on the extension suffix. |
Examples | ['t', 'd'] , etc. |
Required | True |
abi.extension_suffix
Type | string |
Description | Suffix used for extensions built against the current
implementation version. This field MUST be present if the Python implementation supports extensions, otherwise this entry will be missing. |
Examples |
|
Required | True |
abi.stable_abi_suffix
Type | string |
Description | Suffix used for extensions built against the stable ABI. This field MUST be present if the Python implementation has a stable ABI extension suffix, otherwise this entry will be missing. |
Examples | .abi3.so , etc. |
Required | False |
suffixes
Type | object |
Description | Valid module suffixes grouped by type. This section SHOULD be equivalent to the
|
Examples |
|
Required | False |
Additional properties | Allowed |
libpython
Type | object |
Description | Object containing details related to the libpython library.This section MUST by present if Python installation provides a
|
Required | False |
Additional properties | Not allowed |
libpython.dynamic
Type | string |
Description | The path to the dynamic libpython library. Either an
absolute path, or a relative path to the path defined in the
base_prefix key.This field MUST be present if the Python installation provides a
dynamic |
Examples |
|
Required | False |
libpython.dynamic_stableabi
Type | string |
Description | The path to the dynamic libpython library for the stable
ABI. Either an absolute path, or a relative path to the path
defined in the base_prefix key.This field MUST be present if the Python installation provides a
dynamic |
Examples |
|
Required | False |
libpython.static
Type | string |
Description | The path to the static libpython library. Either an absolute
path, or a relative path to the path defined in the
base_prefix key.This field MUST be present if the Python installation provides a
static |
Examples |
|
Required | False |
libpython.link_to_libpython
Type | boolean |
Description | Should extensions built against a dynamic libpython link to
it?This field MUST be present if the Python installation provides a
dynamic |
Required | False |
c_api
Type | object |
Description | Object containing details related to the Python C API, if
available. This section MUST be present if the Python implementation provides a C API, otherwise this section will be missing. |
Required | False |
Additional properties | Not allowed |
c_api.headers
Type | string |
Description | The path to the C API headers. Either an absolute path, or a
relative path to the path defined in the base_prefix key. |
Examples |
|
Required | True |
c_api.pkgconfig_path
Type | string |
Description | The path to the pkg-config definition files. Either an absolute
path, or a relative path to the path defined in the
base_prefix key.This field MUST be present if the Python implementation provides pkg-config definition files for the C API, otherwise this section will be missing. |
Examples |
|
Required | False |
arbitrary_data
Type | object |
Description | Object containing extra arbitrary data. This is meant to be used as an escape-hatch, to include any relevant data that is not covered by this specification. Implamentations may choose what data to provide in this section. |
Required | False |
Additional properties | Allowed |
Example
1{
2 "schema_version": "1.0",
3 "base_prefix": "/usr",
4 "platform": "linux-x86_64",
5 "language": {
6 "version": "3.14",
7 "version_info": {
8 "major": 3,
9 "minor": 14,
10 "micro": 0,
11 "releaselevel": "alpha",
12 "serial": 0
13 }
14 },
15 "implementation": {
16 "name": "cpython",
17 "version": {
18 "major": 3,
19 "minor": 14,
20 "micro": 0,
21 "releaselevel": "alpha",
22 "serial": 0
23 },
24 "hexversion": 51249312,
25 "cache_tag": "cpython-314",
26 "_multiarch": "x86_64-linux-gnu"
27 },
28 "interpreter": {
29 "path": "/usr/bin/python"
30 },
31 "abi": {
32 "flags": ["t", "d"],
33 "extension_suffix": ".cpython-314-x86_64-linux-gnu.so",
34 "stable_abi_suffix": ".abi3.so"
35 },
36 "suffixes": {
37 "source": [".py"],
38 "bytecode": [".pyc"],
39 "optimized_bytecode": [".pyc"],
40 "debug_bytecode": [".pyc"],
41 "extensions": [".cpython-314-x86_64-linux-gnu.so", ".abi3.so", ".so"]
42 },
43 "libpython": {
44 "dynamic": "/usr/lib/libpython3.14.so.1.0",
45 "dynamic_stableabi": "/usr/lib/libpython3.so",
46 "static": "/usr/lib/python3.14/config-3.14-x86_64-linux-gnu/libpython3.14.a",
47 "link_to_libpython": true
48 },
49 "c_api": {
50 "headers": "/usr/include/python3.14",
51 "pkgconfig_path": "/usr/lib/pkgconfig"
52 }
53}
JSON Schema
1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "$id": "https://github.com/python/peps/blob/main/peps/pep-0739/python-build-info-v1.0.schema.json",
4 "type": "object",
5 "title": "Static description file for the build details of Python installations",
6 "required": [
7 "schema_version",
8 "platform",
9 "language",
10 "implementation"
11 ],
12 "additionalProperties": false,
13 "properties": {
14 "schema_version": {
15 "type": "string",
16 "description": "Schema version.\n\nThis is a string following the format ``<MAJOR>.<MINOR>``, where ``<MAJOR>`` and ``<MINOR>`` are unpaded numbers and represent the **major** and **minor** components of the version. Versions may be arithmetic compared by intrepreting the version string as a decimal number.\n\nFor this specification version, this value is constant and MUST be ``1.0``.\n\nFuture versions of this schema MUST use a higher version number. Future versions of this schema MUST NOT use the same **major** version component as other schema version unless its specification is deemed backwards-compatible with them — it can't change, or extend, any parts of the current specification in such a way as the semantics of the interpreted data differ, or that data valid under the new specification is invalid under the older specification, with the exception of additional properties (errors caused by ``additionalProperties``).",
17 "const": "1.0"
18 },
19 "base_prefix": {
20 "type": "string",
21 "description": "Base prefix of the Python installation.\n\nEither an absolute path, or a relative path to directory where this file is contained.",
22 "examples": [
23 "/usr",
24 "../.."
25 ]
26 },
27 "platform": {
28 "type": "string",
29 "description": "System platform string.\n\nThis field SHOULD be equivalent to ``sysconfig.get_platform()``.",
30 "examples": [
31 "linux-x86_64"
32 ]
33 },
34 "language": {
35 "type": "object",
36 "description": "Object containing details related to the Python language specification.\n\nIn addition to the required keys, implementations may choose to include extra keys with implementation-specific details.",
37 "required": [
38 "version"
39 ],
40 "additionalProperties": false,
41 "properties": {
42 "version": {
43 "type": "string",
44 "description": "String representation the Python language version — a version string consisting only of the *major* and *minor* components.\n\nThis field SHOULD be equivalent to ``sysconfig.get_python_version()``.",
45 "examples": ["3.14"]
46 },
47 "version_info": {
48 "type": "object",
49 "description": "Object in the format of :py:data:`sys.version_info`.\n\nThis section SHOULD be equivalent to :py:data:`sys.version_info`.",
50 "required": ["major", "minor", "micro", "releaselevel", "serial"],
51 "additionalProperties": false,
52 "examples": [
53 {
54 "major": 3,
55 "minor": 14,
56 "micro": 1,
57 "releaselevel": "final",
58 "serial": 0
59 }
60 ],
61 "properties": {
62 "major": {
63 "type": "number"
64 },
65 "minor": {
66 "type": "number"
67 },
68 "micro": {
69 "type": "number"
70 },
71 "releaselevel": {
72 "type": "string",
73 "enum": ["alpha", "beta", "candidate", "final"]
74 },
75 "serial": {
76 "type": "number"
77 }
78 }
79 }
80 }
81 },
82 "implementation": {
83 "type": "object",
84 "description": "Object containing details related to Python implementation.\n\nThis section SHOULD be equivalent to :py:data:`sys.implementation`. It follows specification defined in PEP 421, meaning that on top of the required keys, implementation-specific keys can also exist, but must be prefixed with an underscore.",
85 "required": [
86 "name",
87 "version",
88 "hexversion",
89 "cache_tag"
90 ],
91 "additionalProperties": true,
92 "properties": {
93 "name": {
94 "type": "string",
95 "description": "Lower-case name of the Python implementation.",
96 "examples": ["cpython", "pypy"]
97 },
98 "version": {
99 "type": "object",
100 "description": "Object in the format of :py:data:`sys.version_info`, containing the implementation version.",
101 "required": ["major", "minor", "micro", "releaselevel", "serial"],
102 "additionalProperties": false,
103 "examples": [
104 {
105 "major": 3,
106 "minor": 14,
107 "micro": 1,
108 "releaselevel": "final",
109 "serial": 0
110 },
111 {
112 "major": 7,
113 "minor": 3,
114 "micro": 16,
115 "releaselevel": "final",
116 "serial": 0
117 }
118 ],
119 "properties": {
120 "major": {
121 "type": "number"
122 },
123 "minor": {
124 "type": "number"
125 },
126 "micro": {
127 "type": "number"
128 },
129 "releaselevel": {
130 "type": "string",
131 "enum": ["alpha", "beta", "candidate", "final"]
132 },
133 "serial": {
134 "type": "number"
135 }
136 }
137 }
138 }
139 },
140 "interpreter": {
141 "type": "object",
142 "description": "Object containing details Python interpreter.\n\nThis section MUST be present if the Python installation provides an interpreter binary, otherwise this section will be missing.",
143 "required": [
144 "path"
145 ],
146 "additionalProperties": false,
147 "properties": {
148 "path": {
149 "type": "string",
150 "description": "The path to the Python interprer. Either an absolute path, or a relative path to the path defined in the ``base_prefix`` key.",
151 "examples": [
152 "/usr/bin/python",
153 "bin/python"
154 ]
155 }
156 }
157 },
158 "abi": {
159 "type": "object",
160 "description": "Object containing details related to ABI.",
161 "required": [
162 "flags",
163 "extension_suffix"
164 ],
165 "additionalProperties": false,
166 "properties": {
167 "flags": {
168 "type": "array",
169 "description": "Build configuration flags, used to calculate the extension suffix.\n\nThe flags MUST be defined in the order they appear on the extension suffix.",
170 "additionalProperties": true,
171 "examples": [
172 ["t", "d"]
173 ]
174 },
175 "extension_suffix": {
176 "type": "string",
177 "description": "Suffix used for extensions built against the current implementation version.\n\nThis field MUST be present if the Python implementation supports extensions, otherwise this entry will be missing.",
178 "examples": [
179 ".cpython-314-x86_64-linux-gnu.so"
180 ]
181 },
182 "stable_abi_suffix": {
183 "type": "string",
184 "description": "Suffix used for extensions built against the stable ABI.\n\nThis field MUST be present if the Python implementation has a stable ABI extension suffix, otherwise this entry will be missing.",
185 "examples": [
186 ".abi3.so"
187 ]
188 }
189 }
190 },
191 "suffixes": {
192 "type": "object",
193 "description": "Valid module suffixes grouped by type.\n\nThis section SHOULD be equivalent to the ``importlib.machinery.*_SUFFIXES`` attributes, if the implementation provides such suffixes. However, if the Python implementation does not provide suffixes of the kind specified by any of the attributes, the equivalent sub-section is not required to be present. Additionally, if a Python implementation provides extension kinds other than the ones listed on ``importlib.machinery`` module, they MAY add a sub-section for them.",
194 "examples": [
195 {
196 "source": [".py"],
197 "bytecode": [".pyc"],
198 "optimized_bytecode": [".pyc"],
199 "debug_bytecode": [".pyc"],
200 "extensions": [".cpython-313-x86_64-linux-gnu.so", ".abi3.so", ".so"]
201 }
202 ]
203 },
204 "libpython": {
205 "type": "object",
206 "description": "Object containing details related to the ``libpython`` library.\n\nThis section MUST by present if Python installation provides a ``libpython`` library, otherwise this section will be missing.",
207 "additionalProperties": false,
208 "properties": {
209 "dynamic": {
210 "type": "string",
211 "description": "The path to the dynamic ``libpython`` library. Either an absolute path, or a relative path to the path defined in the ``base_prefix`` key.\n\nThis field MUST be present if the Python installation provides a dynamic ``libpython`` library, otherwise this entry will be missing.",
212 "examples": [
213 "/usr/lib/libpython3.14.so.1.0",
214 "lib/libpython3.14.so.1.0"
215 ]
216 },
217 "dynamic_stableabi": {
218 "type": "string",
219 "description": "The path to the dynamic ``libpython`` library for the stable ABI. Either an absolute path, or a relative path to the path defined in the ``base_prefix`` key.\n\nThis field MUST be present if the Python installation provides a dynamic ``libpython`` library, otherwise this entry will be missing.",
220 "examples": [
221 "/usr/lib/libpython3.so",
222 "lib/libpython3.so"
223 ]
224 },
225 "static": {
226 "type": "string",
227 "description": "The path to the static ``libpython`` library. Either an absolute path, or a relative path to the path defined in the ``base_prefix`` key.\n\nThis field MUST be present if the Python installation provides a static ``libpython`` library, otherwise this entry will be missing.",
228 "examples": [
229 "/usr/lib/python3.14/config-3.14-x86_64-linux-gnu/libpython3.14.a",
230 "lib/python3.14/config-3.14-x86_64-linux-gnu/libpython3.14.a"
231 ]
232 },
233 "link_to_libpython": {
234 "type": "boolean",
235 "description": "Should extensions built against a dynamic ``libpython`` link to it?\n\nThis field MUST be present if the Python installation provides a dynamic ``libpython`` library, otherwise this entry will be missing."
236 }
237 }
238 },
239 "c_api": {
240 "type": "object",
241 "description": "Object containing details related to the Python C API, if available.\n\nThis section MUST be present if the Python implementation provides a C API, otherwise this section will be missing.",
242 "required": [
243 "headers"
244 ],
245 "additionalProperties": false,
246 "properties": {
247 "headers": {
248 "type": "string",
249 "description": "The path to the C API headers. Either an absolute path, or a relative path to the path defined in the ``base_prefix`` key.",
250 "examples": [
251 "/usr/include/python3.14",
252 "include/python3.14"
253 ]
254 },
255 "pkgconfig_path": {
256 "type": "string",
257 "description": "The path to the pkg-config definition files. Either an absolute path, or a relative path to the path defined in the ``base_prefix`` key.\n\nThis field MUST be present if the Python implementation provides pkg-config definition files for the C API, otherwise this section will be missing.",
258 "examples": [
259 "/usr/lib/pkgconfig",
260 "lib/pkgconfig"
261 ]
262 }
263 }
264 },
265 "arbitrary_data": {
266 "type": "object",
267 "description": "Object containing extra arbitrary data.\n\nThis is meant to be used as an escape-hatch, to include any relevant data that is not covered by this specification. Implamentations may choose what data to provide in this section.",
268 "additionalProperties": true
269 }
270 }
271}
Rejected Ideas
Having a larger scope
One of the main requests in the discussion of this PEP was the inclusion of
other kind of information, such as the site-packages
path. It is the opinion
of the PEP authors that information regarding the Python environment should be
provided by a separate file, creating the a clear separation between the build
details, which should be immutable across any interpreter instance, and details
that can change, such as environment details.
Copyright
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-0739.rst
Last modified: 2024-11-06 17:11:55 GMT