@@ -9,27 +9,103 @@ Platform compatibility tags allow build tools to mark distributions as being
99compatible with specific platforms, and allows installers to understand which
1010distributions are compatible with the system they are running on.
1111
12- The platform compatibility tagging model used for the ``wheel `` distribution
13- format is defined in :pep: `425 `.
12+ The following PEPs contributed to this spec:
1413
15- Platform tags for Windows
16- -------------------------
14+ 1. :pep: `425 `
15+ 2. :pep: `513 `
16+ 3. :pep: `571 `
17+ 4. :pep: `599 `
18+ 5. :pep: `600 `
1719
18- The scheme defined in :pep: ` 425 ` covers public distribution of wheel files to
19- systems running Windows.
20+ Overview
21+ ========
2022
21- Platform tags for macOS (Mac OS X)
22- ----------------------------------
23+ The tag format is ``{python tag}-{abi tag}-{platform tag} ``.
2324
24- The scheme defined in :pep: `425 ` covers public distribution of wheel files to
25- systems running macOS (previously known as Mac OS X).
25+ python tag
26+ 'py27', 'cp33'
27+ abi tag
28+ 'cp32dmu', 'none'
29+ platform tag
30+ 'linux_x86_64', 'any'
2631
27- Platform tags for common Linux distributions
28- --------------------------------------------
32+ For example, the tag `` py27-none-any `` indicates compatibility with Python 2.7
33+ (any Python 2.7 implementation) with no abi requirement, on any platform.
2934
35+ Use
36+ ===
37+
38+ The ``wheel `` built package format includes these tags in its filenames,
39+ of the form
40+ ``{distribution}-{version}(-{build tag})?-{python tag}-{abitag}-{platform tag}.whl ``.
41+ Other package formats may have their own conventions.
42+
43+ Any potential spaces in any tag should be replaced with ``_ ``.
44+
45+ Details
46+ =======
47+
48+ Python Tag
49+ ----------
50+
51+ The Python tag indicates the implementation and version required by
52+ a distribution. Major implementations have abbreviated codes, initially:
53+
54+ * py: Generic Python (does not require implementation-specific features)
55+ * cp: CPython
56+ * ip: IronPython
57+ * pp: PyPy
58+ * jy: Jython
59+
60+ Other Python implementations should use ``sys.implementation.name ``.
61+
62+ The version is ``py_version_nodot ``. CPython gets away with no dot,
63+ but if one is needed the underscore ``_ `` is used instead. PyPy should
64+ probably use its own versions here ``pp18 ``, ``pp19 ``.
65+
66+ The version can be just the major version ``2 `` or ``3 `` ``py2 ``, ``py3 `` for
67+ many pure-Python distributions.
68+
69+ Importantly, major-version-only tags like ``py2 `` and ``py3 `` are not
70+ shorthand for ``py20 `` and ``py30 ``. Instead, these tags mean the packager
71+ intentionally released a cross-version-compatible distribution.
72+
73+ A single-source Python 2/3 compatible distribution can use the compound
74+ tag ``py2.py3 ``. See `Compressed Tag Sets `_, below.
75+
76+ ABI Tag
77+ -------
78+
79+ The ABI tag indicates which Python ABI is required by any included
80+ extension modules. For implementation-specific ABIs, the implementation
81+ is abbreviated in the same way as the Python Tag, e.g. ``cp33d `` would be
82+ the CPython 3.3 ABI with debugging.
83+
84+ The CPython stable ABI is ``abi3 `` as in the shared library suffix.
85+
86+ Implementations with a very unstable ABI may use the first 6 bytes (as
87+ 8 base64-encoded characters) of the SHA-256 hash of their source code
88+ revision and compiler flags, etc, but will probably not have a great need
89+ to distribute binary distributions. Each implementation's community may
90+ decide how to best use the ABI tag.
91+
92+ Platform Tag
93+ ------------
94+
95+ The platform tag is simply ``distutils.util.get_platform() `` with all
96+ hyphens ``- `` and periods ``. `` replaced with underscore ``_ ``.
97+
98+ * win32
99+ * linux_i386
100+ * linux_x86_64
101+
102+
103+ -------------
104+ ``manylinux ``
105+ -------------
30106.. _manylinux :
31107
32- The scheme defined in :pep: `425 ` is insufficient for public distribution of
108+ The scheme defined in :pep: `425 ` was insufficient for public distribution of
33109wheel files (and \* nix wheel files in general) to Linux platforms, due to the
34110large ecosystem of Linux platforms and subtle differences between them.
35111
@@ -86,13 +162,141 @@ pip ``>=8.1.0`` ``>=19.0`` ``>=19.3`` ``>=20.3``
86162auditwheel ``>=1.0.0 `` ``>=2.0.0 `` ``>=3.0.0 `` ``>=3.3.0 `` [# ]_
87163========== ============== ================= ================= =================
88164
89- Platform tags for other \* nix platforms
90- ---------------------------------------
165+ .. [# ] Only support for ``manylinux_2_24 `` has been added in auditwheel 3.3.0
91166
92- The scheme defined in :pep: `425 ` is not generally sufficient for public
93- distribution of wheel files to other \* nix platforms. Efforts are currently
94- (albeit intermittently) under way to define improved compatibility tagging
95- schemes for AIX and for Alpine Linux.
167+ Use
168+ ===
96169
170+ The tags are used by installers to decide which built distribution
171+ (if any) to download from a list of potential built distributions.
172+ The installer maintains a list of (pyver, abi, arch) tuples that it
173+ will support. If the built distribution's tag is ``in `` the list, then
174+ it can be installed.
97175
98- .. [# ] Only support for ``manylinux_2_24 `` has been added in auditwheel 3.3.0
176+ It is recommended that installers try to choose the most feature complete
177+ built distribution available (the one most specific to the installation
178+ environment) by default before falling back to pure Python versions
179+ published for older Python releases. Installers are also recommended to
180+ provide a way to configure and re-order the list of allowed compatibility
181+ tags; for example, a user might accept only the ``*-none-any `` tags to only
182+ download built packages that advertise themselves as being pure Python.
183+
184+ Another desirable installer feature might be to include "re-compile from
185+ source if possible" as more preferable than some of the compatible but
186+ legacy pre-built options.
187+
188+ This example list is for an installer running under CPython 3.3 on a
189+ linux_x86_64 system. It is in order from most-preferred (a distribution
190+ with a compiled extension module, built for the current version of
191+ Python) to least-preferred (a pure-Python distribution built with an
192+ older version of Python):
193+
194+ 1. cp33-cp33m-linux_x86_64
195+ 2. cp33-abi3-linux_x86_64
196+ 3. cp3-abi3-linux_x86_64
197+ 4. cp33-none-linux_x86_64*
198+ 5. cp3-none-linux_x86_64*
199+ 6. py33-none-linux_x86_64*
200+ 7. py3-none-linux_x86_64*
201+ 8. cp33-none-any
202+ 9. cp3-none-any
203+ 10. py33-none-any
204+ 11. py3-none-any
205+ 12. py32-none-any
206+ 13. py31-none-any
207+ 14. py30-none-any
208+
209+ * Built distributions may be platform specific for reasons other than C
210+ extensions, such as by including a native executable invoked as
211+ a subprocess.
212+
213+ Sometimes there will be more than one supported built distribution for a
214+ particular version of a package. For example, a packager could release
215+ a package tagged ``cp33-abi3-linux_x86_64 `` that contains an optional C
216+ extension and the same distribution tagged ``py3-none-any `` that does not.
217+ The index of the tag in the supported tags list breaks the tie, and the
218+ package with the C extension is installed in preference to the package
219+ without because that tag appears first in the list.
220+
221+ Compressed Tag Sets
222+ ===================
223+
224+ To allow for compact filenames of bdists that work with more than
225+ one compatibility tag triple, each tag in a filename can instead be a
226+ '.'-separated, sorted, set of tags. For example, pip, a pure-Python
227+ package that is written to run under Python 2 and 3 with the same source
228+ code, could distribute a bdist with the tag ``py2.py3-none-any ``.
229+ The full list of simple tags is::
230+
231+ for x in pytag.split('.'):
232+ for y in abitag.split('.'):
233+ for z in archtag.split('.'):
234+ yield '-'.join((x, y, z))
235+
236+ A bdist format that implements this scheme should include the expanded
237+ tags in bdist-specific metadata. This compression scheme can generate
238+ large numbers of unsupported tags and "impossible" tags that are supported
239+ by no Python implementation e.g. "cp33-cp31u-win64", so use it sparingly.
240+
241+ FAQ
242+ ===
243+
244+ What tags are used by default?
245+ Tools should use the most-preferred architecture dependent tag
246+ e.g. ``cp33-cp33m-win32 `` or the most-preferred pure python tag
247+ e.g. ``py33-none-any `` by default. If the packager overrides the
248+ default it indicates that they intended to provide cross-Python
249+ compatibility.
250+
251+ What tag do I use if my distribution uses a feature exclusive to the newest version of Python?
252+ Compatibility tags aid installers in selecting the *most compatible *
253+ build of a *single version * of a distribution. For example, when
254+ there is no Python 3.3 compatible build of ``beaglevote-1.2.0 ``
255+ (it uses a Python 3.4 exclusive feature) it may still use the
256+ ``py3-none-any `` tag instead of the ``py34-none-any `` tag. A Python
257+ 3.3 user must combine other qualifiers, such as a requirement for the
258+ older release ``beaglevote-1.1.0 `` that does not use the new feature,
259+ to get a compatible build.
260+
261+ Why isn't there a ``. `` in the Python version number?
262+ CPython has lasted 20+ years without a 3-digit major release. This
263+ should continue for some time. Other implementations may use _ as
264+ a delimiter, since both - and . delimit the surrounding filename.
265+
266+ Why normalise hyphens and other non-alphanumeric characters to underscores?
267+ To avoid conflicting with the ``. `` and ``- `` characters that separate
268+ components of the filename, and for better compatibility with the
269+ widest range of filesystem limitations for filenames (including
270+ being usable in URL paths without quoting).
271+
272+ Why not use special character <X> rather than ``. `` or ``- ``?
273+ Either because that character is inconvenient or potentially confusing
274+ in some contexts (for example, ``+ `` must be quoted in URLs, ``~ `` is
275+ used to denote the user's home directory in POSIX), or because the
276+ advantages weren't sufficiently compelling to justify changing the
277+ existing reference implementation for the wheel format defined in :pep: 427
278+ (for example, using ``, `` rather than ``. `` to separate components
279+ in a compressed tag).
280+
281+ Who will maintain the registry of abbreviated implementations?
282+ New two-letter abbreviations can be requested on the python-dev
283+ mailing list. As a rule of thumb, abbreviations are reserved for
284+ the current 4 most prominent implementations.
285+
286+ Does the compatibility tag go into METADATA or PKG-INFO?
287+ No. The compatibility tag is part of the built distribution's
288+ metadata. METADATA / PKG-INFO should be valid for an entire
289+ distribution, not a single build of that distribution.
290+
291+ Why didn't you mention my favorite Python implementation?
292+ The abbreviated tags facilitate sharing compiled Python code in a
293+ public index. Your Python implementation can use this specification
294+ too, but with longer tags.
295+ Recall that all "pure Python" built distributions just use ``py ``.
296+
297+ Why is the ABI tag (the second tag) sometimes "none" in the reference implementation?
298+ Since Python 2 does not have an easy way to get to the SOABI
299+ (the concept comes from newer versions of Python 3) the reference
300+ implementation at the time of writing guesses "none". Ideally it
301+ would detect "py27(d|m|u)" analogous to newer versions of Python,
302+ but in the meantime "none" is a good enough way to say "don't know".
0 commit comments