Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 13 additions & 180 deletions docs/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,67 +39,13 @@ High Level Interface
The following functions are the main interface to the library, and are typically the only
items that applications should need to reference, in order to parse and check tags.

.. class:: Tag(interpreter, abi, platform)
.. autoclass:: Tag
:members:

A representation of the tag triple for a wheel. Instances are considered
immutable and thus are hashable. Equality checking is also supported.
.. autofunction:: parse_tag

:param str interpreter: The interpreter name, e.g. ``"py"``
(see :attr:`INTERPRETER_SHORT_NAMES` for mapping
well-known interpreter names to their short names).
:param str abi: The ABI that a wheel supports, e.g. ``"cp37m"``.
:param str platform: The OS/platform the wheel supports,
e.g. ``"win_amd64"``.
.. autofunction:: sys_tags

.. attribute:: interpreter

The interpreter name.

.. attribute:: abi

The supported ABI.

.. attribute:: platform

The OS/platform.


.. function:: parse_tag(tag)

Parses the provided ``tag`` into a set of :class:`Tag` instances.

Returning a set is required due to the possibility that the tag is a
`compressed tag set`_, e.g. ``"py2.py3-none-any"`` which supports both
Python 2 and Python 3.

:param str tag: The tag to parse, e.g. ``"py3-none-any"``.


.. function:: sys_tags(*, warn=False)

Yields the tags that the running interpreter supports.

The iterable is ordered so that the best-matching tag is first in the
sequence. The exact preferential order to tags is interpreter-specific, but
in general the tag importance is in the order of:

1. Interpreter
2. Platform
3. ABI

This order is due to the fact that an ABI is inherently tied to the
platform, but platform-specific code is not necessarily tied to the ABI. The
interpreter is the most important tag as it dictates basic support for any
wheel.

The function returns an iterable in order to allow for the possible
short-circuiting of tag generation if the entire sequence is not necessary
and tag calculation happens to be expensive.

:param bool warn: Whether warnings should be logged. Defaults to ``False``.

.. versionchanged:: 21.3
Added the `pp3-none-any` tag (:issue:`311`).


Low Level Interface
Expand All @@ -121,137 +67,24 @@ to the implementation to provide.
(e.g. ``"cpython"`` is ``"cp"``). All interpreter names are lower-case.


.. function:: interpreter_name()

Returns the running interpreter's name.

This typically acts as the prefix to the :attr:`~Tag.interpreter` tag.


.. function:: interpreter_version(*, warn=False)

Returns the running interpreter's version.

This typically acts as the suffix to the :attr:`~Tag.interpreter` tag.


.. function:: mac_platforms(version=None, arch=None)

Yields the :attr:`~Tag.platform` tags for macOS.

:param tuple version: A two-item tuple representing the version of macOS.
Defaults to the current system's version.
:param str arch: The CPU architecture. Defaults to the architecture of the
current system, e.g. ``"x86_64"``.

.. note::
Equivalent support for the other major platforms is purposefully not
provided:

- On Windows, platform compatibility is statically specified
- On Linux, code must be run on the system itself to determine
compatibility


.. function:: ios_platforms(version=None, multiarch=None)

Yields the :attr:`~Tag.platform` tags for iOS.

:param tuple version: A two-item tuple representing the version of iOS.
Defaults to the current system's version.
:param str multiarch: The CPU architecture+ABI to be used. This should be in
the format by ``sys.implementation._multiarch`` (e.g.,
``arm64_iphoneos`` or ``x86_64_iphonesimulator``).
Defaults to the current system's multiarch value.

.. note::
Behavior of this method is undefined if invoked on non-iOS platforms
without providing explicit version and multiarch arguments.


.. function:: android_platforms(api_level=None, abi=None)

Yields the :attr:`~Tag.platform` tags for Android. If this function is invoked on
non-Android platforms, the ``api_level`` and ``abi`` arguments are required.

:param int api_level: The maximum `API level
<https://developer.android.com/tools/releases/platforms>`__ to return. Defaults
to the current system's version, as returned by ``platform.android_ver``.
:param str abi: The `Android ABI <https://developer.android.com/ndk/guides/abis>`__,
e.g. ``arm64_v8a``. Defaults to the current system's ABI, as returned by
``sysconfig.get_platform``. Hyphens and periods will be replaced with
underscores.


.. function:: platform_tags(version=None, arch=None)

Yields the :attr:`~Tag.platform` tags for the running interpreter.


.. function:: compatible_tags(python_version=None, interpreter=None, platforms=None)

Yields the tags for an interpreter compatible with the Python version
specified by ``python_version``.

The specific tags generated are:

- ``py*-none-<platform>``
- ``<interpreter>-none-any`` if ``interpreter`` is provided
- ``py*-none-any``

:param Sequence python_version: A one- or two-item sequence representing the
compatible version of Python. Defaults to
``sys.version_info[:2]``.
:param str interpreter: The name of the interpreter (if known), e.g.
``"cp38"``. Defaults to the current interpreter.
:param Iterable platforms: Iterable of compatible platforms. Defaults to the
platforms compatible with the current system.

.. function:: cpython_tags(python_version=None, abis=None, platforms=None, *, warn=False)

Yields the tags for the CPython interpreter.

The specific tags generated are:

- ``cp<python_version>-<abi>-<platform>``
- ``cp<python_version>-abi3-<platform>``
- ``cp<python_version>-none-<platform>``
- ``cp<older version>-abi3-<platform>`` where "older version" is all older
minor versions down to Python 3.2 (when ``abi3`` was introduced)
.. autofunction:: interpreter_name

If ``python_version`` only provides a major-only version then only
user-provided ABIs via ``abis`` and the ``none`` ABI will be used.
.. autofunction:: interpreter_version

:param Sequence python_version: A one- or two-item sequence representing the
targeted Python version. Defaults to
``sys.version_info[:2]``.
:param Iterable abis: Iterable of compatible ABIs. Defaults to the ABIs
compatible with the current system.
:param Iterable platforms: Iterable of compatible platforms. Defaults to the
platforms compatible with the current system.
:param bool warn: Whether warnings should be logged. Defaults to ``False``.
.. autofunction:: mac_platforms

.. function:: generic_tags(interpreter=None, abis=None, platforms=None, *, warn=False)
.. autofunction:: ios_platforms

Yields the tags for an interpreter which requires no specialization.
.. autofunction:: android_platforms

This function should be used if one of the other interpreter-specific
functions provided by this module is not appropriate (i.e. not calculating
tags for a CPython interpreter).
.. autofunction:: platform_tags

The specific tags generated are:
.. autofunction:: compatible_tags

- ``<interpreter>-<abi>-<platform>``
.. autofunction:: cpython_tags

The ``"none"`` ABI will be added if it was not explicitly provided.
.. autofunction:: generic_tags

:param str interpreter: The name of the interpreter. Defaults to being
calculated.
:param Iterable abis: Iterable of compatible ABIs. Defaults to the ABIs
compatible with the current system.
:param Iterable platforms: Iterable of compatible platforms. Defaults to the
platforms compatible with the current system.
:param bool warn: Whether warnings should be logged. Defaults to ``False``.

.. _`abbreviation codes`: https://www.python.org/dev/peps/pep-0425/#python-tag
.. _`compressed tag set`: https://www.python.org/dev/peps/pep-0425/#compressed-tag-sets
Expand Down
Loading
Loading