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

Parse raw metadata #671

Merged
merged 33 commits into from Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3a097a3
Implement RawMetadata
brettcannon Jan 16, 2023
4be6034
Minor tweaks
brettcannon Jan 16, 2023
f5174f4
Add tests for field frequency handling
brettcannon Jan 16, 2023
1a1dc80
Test `keywords`
brettcannon Jan 16, 2023
fe70df3
Add tests for `Project-URL` parsing
brettcannon Jan 16, 2023
62cb64f
Test `str` and `bytes` input
brettcannon Jan 16, 2023
bd86a21
Test handling of `description`
brettcannon Jan 17, 2023
25b320a
Don't worry about multi-part email bodies
brettcannon Jan 21, 2023
f0e5271
Test that keys are lower-cased
brettcannon Jan 21, 2023
1670328
Support using `pathlib.Path` in `_manylinux`
brettcannon Jan 22, 2023
ac3190f
Add a complete test
brettcannon Jan 23, 2023
28a9480
`abc.ABC` is not subscriptable until Python 3.9
brettcannon Jan 23, 2023
ae014d6
`TypedDict` was introduced in Python 3.8
brettcannon Jan 23, 2023
4f9aa08
Linting touch-ups
brettcannon Jan 23, 2023
fb5db93
Remove code path that never seems to be exercised
brettcannon Jan 23, 2023
a81ede7
Linting touch-ups
brettcannon Jan 23, 2023
d466ddb
Make mypy happy
brettcannon Jan 23, 2023
d1bd707
Drop 3.7 support
brettcannon Jan 23, 2023
8561ece
Add docs
brettcannon Jan 24, 2023
d86e436
Merge branch 'main' into raw-metadata
brettcannon Jan 24, 2023
4d97abe
Apply suggestions from code review
brettcannon Jan 24, 2023
76062f3
Update tests/metadata/everything.metadata
brettcannon Jan 24, 2023
004f136
Update a test
brettcannon Jan 25, 2023
2674e55
Make isort happy
brettcannon Jan 25, 2023
4164911
Be compatible with Python 3.7
brettcannon Jan 31, 2023
9366d3a
Merge branch 'main' into raw-metadata
brettcannon Jan 31, 2023
31e1b22
More 3.7 support
brettcannon Jan 31, 2023
492d678
Merge branch 'raw-metadata' of github.com:brettcannon/packaging into …
brettcannon Jan 31, 2023
f8ded2f
Poetry via pip via pep517 isn't happy
brettcannon Jan 31, 2023
6ce6b97
Try to get around isort triggering a failure via Poetry
brettcannon Jan 31, 2023
f0c6c61
Try another suggestion on how to make `TypedDict` not error out in Py…
brettcannon Feb 1, 2023
ebe3e30
Merge branch 'main' into raw-metadata
brettcannon Feb 1, 2023
092e153
Merge branch 'main' into raw-metadata
brettcannon Feb 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -27,7 +27,7 @@ repos:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
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
@@ -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
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
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.
brettcannon marked this conversation as resolved.
Show resolved Hide resolved
@contextlib.contextmanager
def _parse_elf(path: str) -> Generator[Optional[ELFFile], None, None]:
try:
Expand Down