Skip to content

Commit

Permalink
Parse raw metadata (#671)
Browse files Browse the repository at this point in the history
Co-authored-by: Donald Stufft <donald@stufft.io>
Co-authored-by: Paul Moore <p.f.moore@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
  • Loading branch information
4 people committed Feb 1, 2023
1 parent 96d85be commit 7722044
Show file tree
Hide file tree
Showing 9 changed files with 749 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
os: [Ubuntu, Windows, macOS]
python_version:
["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.8", "pypy3.9"]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can install packaging with ``pip``:
specifiers
markers
requirements
metadata
tags
utils

Expand Down
42 changes: 42 additions & 0 deletions docs/metadata.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Metadata
========

.. currentmodule:: packaging.markers


Both `source distributions`_ and `binary distributions`
(_sdists_ and _wheels_, respectively) contain files recording the
`core metadata`_ for the distribution. This information is used for
everything from recording the name of the distribution to the
installation dependencies.


Usage
-----

.. doctest::

>>> from packaging.metadata import parse_email
>>> metadata = "Metadata-Version: 2.3\nName: packaging\nVersion: 24.0"
>>> raw, unparsed = parse_email(metadata)
>>> raw["metadata_version"]
'2.3'
>>> raw["name"]
'packaging'
>>> raw["version"]
'24.0'


Reference
---------

Low Level Interface
'''''''''''''''''''

.. automodule:: packaging.metadata
:members:


.. _source distributions: https://packaging.python.org/en/latest/specifications/source-distribution-format/
.. _binary distributions: https://packaging.python.org/en/latest/specifications/binary-distribution-format/
.. _core metadata: https://packaging.python.org/en/latest/specifications/core-metadata/
4 changes: 1 addition & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
nox.options.reuse_existing_virtualenvs = True


@nox.session(
python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
)
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.8", "pypy3.9"])
def tests(session):
def coverage(*args):
session.run("python", "-m", "coverage", *args)
Expand Down
2 changes: 2 additions & 0 deletions src/packaging/_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
EF_ARM_ABI_FLOAT_HARD = 0x00000400


# `os.PathLike` not a generic type until Python 3.9, so sticking with `str`
# as the type for `path` until then.
@contextlib.contextmanager
def _parse_elf(path: str) -> Generator[Optional[ELFFile], None, None]:
try:
Expand Down
Loading

0 comments on commit 7722044

Please sign in to comment.