Skip to content

Commit

Permalink
rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
fangchenli committed Aug 10, 2023
2 parents b797a3e + 3030822 commit 1702c7a
Show file tree
Hide file tree
Showing 48 changed files with 2,896 additions and 1,578 deletions.
9 changes: 0 additions & 9 deletions .coveragerc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
cache: "pip"

- name: Run `nox -s lint`
run: pipx run nox --error-on-missing-interpreters -s lint
run: pipx run nox --error-on-missing-interpreters -s lint -- --show-diff-on-failure

build:
name: Build sdist and wheel
runs-on: ubuntu-latest
# Linting verifies that the project is in an acceptable state to create files
# for releasing.
# And this action should be run whenever a release is ready to go public as
# the version number will be changed by editing __about__.py.
# the version number will be changed by editing __init__.py.
needs: lint

steps:
Expand Down
3 changes: 2 additions & 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", "pypy3.7", "pypy3.8", "pypy3.9"]
["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9", "pypy3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -33,6 +33,7 @@ jobs:
with:
python-version: ${{ matrix.python_version }}
cache: "pip"
allow-prereleases: true

- name: Run nox
run: pipx run nox --error-on-missing-interpreters -s tests-${{ matrix.python_version }}
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.950
rev: v0.991
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: []
additional_dependencies: [pyparsing, nox]

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.12.0
hooks:
- id: black

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

- repo: https://github.com/PyCQA/flake8
rev: "3.9.2"
rev: "6.0.0"
hooks:
- id: flake8
additional_dependencies: ["pep8-naming"]
Expand Down
53 changes: 51 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,59 @@ Changelog
*unreleased*
~~~~~~~~~~~~

* Enforce that the entire marker string is parsed (:issue:`687`)
* Requirement parsing no longer automatically validates the URL (:issue:`120`)
* Canonicalize names for requirements comparison (:issue:`644`)

23.1 - 2023-04-12
~~~~~~~~~~~~~~~~~

* Parse raw metadata (:issue:`671`)
* Import underlying parser functions as an underscored variable (:issue:`663`)
* Improve error for local version label with unsupported operators (:issue:`675`)
* Add dedicated error for specifiers with incorrect `.*` suffix
* Replace spaces in platform names with underscores (:issue:`620`)
* Relax typing of ``_key`` on ``_BaseVersion`` (:issue:`669`)
* Handle prefix match with zeros at end of prefix correctly (:issue:`674`)

23.0 - 2023-01-08
~~~~~~~~~~~~~~~~~

* Allow ``"extra"`` to be ``None`` in the marker environment (:issue:`650`)
* Refactor ``tags._generic_api`` to use ``EXT_SUFFIX`` (:issue:`607`)
* Correctly handle trailing whitespace on URL requirements (:issue:`642`)
* Fix typing for ``specifiers.BaseSpecifier.filter()`` (:issue:`643`)
* Use stable Python 3.11 in tests (:issue:`641`)
* Correctly handle non-normalised specifiers in requirements (:issue:`634`)
* Move to ``src/`` layout (:issue:`626`)
* Remove ``__about__`` file, in favour of keeping constants in ``__init__`` (:issue:`626`)

22.0 - 2022-12-07
~~~~~~~~~~~~~~~~~

* Explicitly declare support for Python 3.11 (:issue:`587`)
* Remove support for Python 3.6 (:issue:`500`)
* Remove ``LegacySpecifier`` and ``LegacyVersion`` (:issue:`407`)
* Add ``__hash__`` and ``__eq__`` to ``Requirement`` (:issue:`499`)
* Add a ``cpNNN-none-any`` tag (:issue:`541`)
* Adhere to :pep:`685` when evaluating markers with extras (:issue:`545`)
* Allow accepting locally installed prereleases with ``SpecifierSet`` (:issue:`515`)
* Allow pre-release versions in marker evaluation (:issue:`523`)
* Correctly parse ELF for musllinux on Big Endian (:issue:`538`)
* Document ``packaging.utils.NormalizedName`` (:issue:`565`)
* Document exceptions raised by functions in ``packaging.utils`` (:issue:`544`)
* Fix compatible version specifier incorrectly strip trailing ``0`` (:issue:`493`)
* Fix macOS platform tags with old macOS SDK (:issue:`513`)
* Forbid prefix version matching on pre-release/post-release segments (:issue:`563`)
* Normalize specifier version for prefix matching (:issue:`561`)
* Improve documentation for ``packaging.specifiers`` and ``packaging.version``. (:issue:`572`)
* ``Marker.evaluate`` will now assume evaluation environment with empty ``extra``.
Evaluating markers like ``"extra == 'xyz'"`` without passing any extra in the
``environment`` will no longer raise an exception.
* Remove dependency on ``pyparsing``, by replacing it with a hand-written parser. This package now has no runtime dependencies (:issue:`468`)
``environment`` will no longer raise an exception (:issue:`550`)
* Remove dependency on ``pyparsing``, by replacing it with a hand-written parser.
This package now has no runtime dependencies (:issue:`468`)
* Update return type hint for ``Specifier.filter`` and ``SpecifierSet.filter``
to use ``Iterator`` instead of ``Iterable`` (:issue:`584`)

21.3 - 2021-11-17
~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ https://packaging.pypa.io/en/latest/development/
Security issues
---------------

To report a security issue, please follow the special `security reporting
guidelines`_, do not report them in the public issue tracker.
See `Security Policy`_ for informations about how to report security issues.

.. _`security reporting guidelines`: https://packaging.pypa.io/en/latest/security/
.. _`Security Policy`: https://github.com/pypa/packaging/security
23 changes: 0 additions & 23 deletions MANIFEST.in

This file was deleted.

5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Security Policy
=========================

To report a security issue, please follow the special [security reporting
guidelines](https://packaging.pypa.io/en/latest/security/), do not report them in the public issue tracker.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ABOUT = {}
_BASE_DIR = os.path.join(os.path.dirname(__file__), os.pardir)
with open(os.path.join(_BASE_DIR, "packaging", "__about__.py")) as f:
with open(os.path.join(_BASE_DIR, "src", "packaging", "__init__.py")) as f:
exec(f.read(), ABOUT)

# -- General configuration ----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ You can install packaging with ``pip``:
specifiers
markers
requirements
tags
metadata
tags
utils

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

A data representation for `core metadata`_.
.. currentmodule:: packaging.markers

.. _`core metadata`: https://packaging.python.org/en/latest/specifications/core-metadata/

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:
:undoc-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/
7 changes: 7 additions & 0 deletions docs/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ Usage
>>> requirements1 == requirements2
True

.. versionchanged:: 23.2

When a requirement is specified with a URL, the :class:`Requirement` class
used to check the URL and reject values containing invalid scheme and
netloc combinations. This is no longer performed since PEP 508 does not
specify such rules, and the check incorrectly disallows valid requirement
strings from being parsed.

Reference
---------
Expand Down
3 changes: 3 additions & 0 deletions docs/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ items that applications should need to reference, in order to parse and check ta

: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 Down
15 changes: 15 additions & 0 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Reference
instance of :class:`~packaging.tags.Tag`.

:param str filename: The name of the wheel file.
:raises InvalidWheelFilename: If the filename in question
does not follow conventions outlined in `PEP 427`_.

.. doctest::

Expand All @@ -87,6 +89,9 @@ Reference
represented by an instance of :class:`~packaging.version.Version`.

:param str filename: The name of the sdist file.
:raises InvalidSdistFilename: If the filename does not end
with an sdist extension (``.zip`` or ``.tar.gz``), or if it does not
contain a dash separating the name and the version of the distribution.

.. doctest::

Expand All @@ -98,4 +103,14 @@ Reference
>>> ver == Version('1.0')
True


.. exception:: InvalidWheelFilename

Raised when a file name for a wheel is invalid.

.. exception:: InvalidSdistFilename

Raised when a source distribution file name is considered invalid.

.. _Source distribution format: https://packaging.python.org/specifications/source-distribution-format/#source-distribution-file-name
.. _`PEP 427`: https://peps.python.org/pep-0427/#file-name-convention
25 changes: 18 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,31 @@
nox.options.reuse_existing_virtualenvs = True


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy3.7", "pypy3.8", "pypy3.9"])
@nox.session(
python=[
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"pypy3.8",
"pypy3.9",
"pypy3.10",
]
)
def tests(session):
def coverage(*args):
session.run("python", "-m", "coverage", *args)

# Once coverage 5 is used then `.coverage` can move into `pyproject.toml`.
session.install("coverage<5.0.0", "pretend", "pytest>=6.2.0", "pip>=9.0.2")
session.install("-r", "tests/requirements.txt")
session.install(".")

if "pypy" not in session.python:
coverage(
"run",
"--source",
"packaging/",
"packaging",
"-m",
"pytest",
"--strict-markers",
Expand All @@ -57,7 +68,7 @@ def coverage(*args):
def lint(session):
# Run the linters (via pre-commit)
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")
session.run("pre-commit", "run", "--all-files", *session.posargs)

# Check the distribution
session.install("build", "twine")
Expand All @@ -68,7 +79,7 @@ def lint(session):
@nox.session(python="3.9")
def docs(session):
shutil.rmtree("docs/_build", ignore_errors=True)
session.install("furo")
session.install("-r", "docs/requirements.txt")
session.install("-e", ".")

variants = [
Expand All @@ -94,7 +105,7 @@ def docs(session):
@nox.session
def release(session):
package_name = "packaging"
version_file = Path(f"{package_name}/__about__.py")
version_file = Path(f"src/{package_name}/__init__.py")
changelog_file = Path("CHANGELOG.rst")

try:
Expand Down

0 comments on commit 1702c7a

Please sign in to comment.