Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose various function in tags publicly #231

Merged
merged 61 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6bfc7bd
Update to mypy 0.740
brettcannon Nov 9, 2019
d703c2d
Change `Optional[bool]` to `bool` as `None` is not expected
brettcannon Nov 9, 2019
0b9e724
Tweak docsstrings to follow the rest of the file
brettcannon Nov 9, 2019
c722ee0
Make linters happy
brettcannon Nov 9, 2019
8c2c701
Initial implementation of public *_tags() functions
brettcannon Nov 9, 2019
fb58d28
Tweak a test name
brettcannon Nov 9, 2019
4494b1c
Add tests for cpython_tags()
brettcannon Nov 9, 2019
d5f8730
Add tests for pypy_tags()
brettcannon Nov 9, 2019
2495a36
Add tests for generic_tags()
brettcannon Nov 9, 2019
5ccac11
Add tests for compatible_tags()
brettcannon Nov 9, 2019
ff3e41f
Type _generic_interpreter()
brettcannon Nov 9, 2019
9f398c5
Add tests for _platform()
brettcannon Nov 9, 2019
8f54af0
Remove now-dead code
brettcannon Nov 9, 2019
11b9bed
Fix the docstring for _py_interpreter_range()
brettcannon Nov 11, 2019
c8e90d9
Expose mac_platforms() publicly
brettcannon Nov 12, 2019
c091101
Make some type hints on parameters more readable
brettcannon Nov 12, 2019
f50ce38
Fix some whitespace
brettcannon Nov 12, 2019
d0b5b56
Fix up tests for mac_platforms() exposure and making platform functio…
brettcannon Nov 12, 2019
5ef9af0
Document new public functions
brettcannon Nov 12, 2019
c59e596
Fix tests
brettcannon Nov 12, 2019
defe719
Remove an extra blank line
brettcannon Nov 13, 2019
ab7cc6d
Fix spelling mistake
brettcannon Nov 15, 2019
c952f2c
Fix a grammar mistake
brettcannon Nov 15, 2019
1fbecf2
Fix spelling mistake
brettcannon Nov 15, 2019
123c1e6
Fix a grammar mistake
brettcannon Nov 15, 2019
818cd09
Fix spelling mistake
brettcannon Nov 15, 2019
b168c09
Provide an interpreter name example
brettcannon Nov 15, 2019
b31be53
Tweak phrasing on adding "none" ABI automatically
brettcannon Nov 15, 2019
7277b5d
Simplify handling of "none" ABI
brettcannon Nov 15, 2019
36c2d81
Tweak how we say mac_platforms() is special
brettcannon Nov 15, 2019
df7751d
Rename _platforms() to _platform_tags()
brettcannon Nov 15, 2019
6c81919
Clarify what generic_tags() is for
brettcannon Nov 15, 2019
ff384e8
Rename _warn_parameters()
brettcannon Nov 15, 2019
3f57469
Clarify a comment
brettcannon Nov 15, 2019
1559ffc
Use backticks instead of * for parameters
brettcannon Nov 15, 2019
bc53e90
Fix a syntax hiccup
brettcannon Nov 15, 2019
adea500
Use `` over * for parameters
brettcannon Nov 15, 2019
205ee20
Drop PyPy-specific code
brettcannon Nov 15, 2019
ddc23de
Touch up _generic_abi()
brettcannon Nov 15, 2019
8f08a0a
Add tests that we are getting back iterators
brettcannon Nov 15, 2019
559cfa0
Merge branch 'master' into expose-tags
brettcannon Nov 15, 2019
5b65b05
Merge remote-tracking branch 'origin/master' into expose-tags
brettcannon Nov 15, 2019
5677fc1
Make Python 2.7 happy
brettcannon Nov 15, 2019
40b2eb7
Group tests
brettcannon Nov 15, 2019
a6dfaf5
Merge branch 'master' of github.com:pypa/packaging into expose-tags
brettcannon Nov 15, 2019
443a209
Remove unnecessary trailing newline
brettcannon Nov 15, 2019
20311bb
Make tests more granular
brettcannon Nov 15, 2019
bb54afd
Touch up the docs
brettcannon Nov 22, 2019
5329072
Expose interpreter_name()
brettcannon Nov 22, 2019
c51ca15
Be more strict about default ABIs
brettcannon Nov 22, 2019
7dc1b66
Use `None` as the default for python_version
brettcannon Nov 22, 2019
1350516
Fix a typing typo
brettcannon Nov 22, 2019
68ea56f
Accept major-only Python versions
brettcannon Nov 22, 2019
a295307
Fix compatibility_tags() tests to actually run
brettcannon Nov 22, 2019
4331ec5
Add a test case for cpython_tags() w/ default ABI and major-only Pyth…
brettcannon Nov 22, 2019
7603a49
Run Black
brettcannon Nov 22, 2019
e62f138
Add interpreter_version()
brettcannon Nov 24, 2019
61666fa
Deal with a type ambiguity
brettcannon Nov 24, 2019
42814d1
Make Python 2.7 happy
brettcannon Nov 24, 2019
b7e61cd
Run Black
brettcannon Nov 24, 2019
66f13d9
Make Python 2.7 happy some more
brettcannon Nov 24, 2019
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.720
rev: v0.740
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
Expand Down
92 changes: 86 additions & 6 deletions docs/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ Reference

.. function:: parse_tag(tag)

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

The returning of a set is required due to the possibility that the tag is a
`compressed tag set`_, e.g. ``"py2.py3-none-any"``.
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)
.. function:: sys_tags(*, warn=False)

Create an iterable of tags that the running interpreter supports.
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
Expand All @@ -92,11 +93,90 @@ Reference

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 calculating some tags happens to be expensive.
and tag calculation happens to be expensive.

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


.. function:: mac_platforms(version=None, arch=None)
brettcannon marked this conversation as resolved.
Show resolved Hide resolved

Yields the platforms tags for macOS.

:param tuple version: A two-item tuple presenting 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:: compatible_tags(python_version=sys.version_info[:2], 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 tuple python_version: A two-item tuple 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"``.
:param Iterable platforms: Iterable of compatible platforms. Defaults to the
platforms compatible with the current system.

.. function:: cpython_tags(python_version=sys.version_info[:2], 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)

:param tuple python_version: A tuple representing the targetted Python
version.
: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``.

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

Yields the tags for an interpreter which requires no specialization.

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).

The specific tags generated are:

- ``<interpreter>-<abi>-<platform>``

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

:param str interpreter: The name of the interpreter. Defaults to being
calculated.
:param Iterable abis: Iterable of compatible ABIs. Defaults to the ABIs
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved
compatible with the current system.
:param Iterable platforms: Iterable of compatible platforms. Defaults to the
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved
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
.. _platform compatibility tags: https://packaging.python.org/specifications/platform-compatibility-tags/
Expand Down
Loading