Skip to content

Commit

Permalink
migrate to parser based on hatchling's
Browse files Browse the repository at this point in the history
- back away from vendoring
- adapt hatchling's license expression parser to accept well-formed LicenseRef-
- back to python storage of license data
  • Loading branch information
ewdurbin committed Sep 5, 2024
1 parent 1aea212 commit cec33f1
Show file tree
Hide file tree
Showing 28 changed files with 1,004 additions and 34,697 deletions.
4 changes: 1 addition & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ repos:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
exclude: '^src/packaging/_vendor'
- id: trailing-whitespace
exclude: '^src/packaging/_vendor'

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

Expand Down
29 changes: 3 additions & 26 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# mypy: disallow-untyped-defs=False, disallow-untyped-calls=False

import argparse
import contextlib
import datetime
import difflib
Expand Down Expand Up @@ -182,32 +181,10 @@ def release(session):
webbrowser.open("https://github.com/pypa/packaging/releases")


# NOTE: This session will COMMIT upgrades to vendored libraries.
# You should therefore not run it directly against `main`. If you
# do (assuming you started with a clean main), you can run:
#
# git checkout -b vendoring-updates
# git checkout main
# git reset --hard origin/main
@nox.session
def vendoring(session: nox.Session) -> None:
# Ensure that the session Python is running 3.10+
# so that truststore can be installed correctly.
session.run(
"python", "-c", "import sys; sys.exit(1 if sys.version_info < (3, 10) else 0)"
)

parser = argparse.ArgumentParser(prog="nox -s vendoring")
parser.add_argument("--upgrade-all", action="store_true")
parser.add_argument("--upgrade", action="append", default=[])
parser.add_argument("--skip", action="append", default=[])
args = parser.parse_args(session.posargs)

session.install("vendoring~=1.2.0")

if not (args.upgrade or args.upgrade_all):
session.run("vendoring", "sync", "-v")
return
def update_licenses(session: nox.Session) -> None:
session.install("httpx")
session.run("python", "tasks/licenses.py")


# -----------------------------------------------------------------------------
Expand Down
28 changes: 2 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,11 @@ Source = "https://github.com/pypa/packaging"

[tool.flit.sdist]
include = ["LICENSE*", "tests/", "docs/", "CHANGELOG.rst"]
exclude = ["docs/_build", "tests/manylinux/build-hello-world.sh", "tests/musllinux/build.sh", "tests/hello-world.c", "tests/__pycache__", "build/__pycache__", "src/packaging/_vendor/license_expression/data/*"]

[tool.pytest.ini_options]
addopts = [
"--ignore=src/packaging/_vendor"
]
exclude = ["docs/_build", "tests/manylinux/build-hello-world.sh", "tests/musllinux/build.sh", "tests/hello-world.c", "tests/__pycache__", "build/__pycache__"]


[tool.coverage.run]
branch = true
omit = [
"*/_vendor/*"
]

[tool.coverage.report]
exclude_lines = ["pragma: no cover", "@abc.abstractmethod", "@abc.abstractproperty"]
Expand All @@ -65,21 +57,12 @@ warn_unused_ignores = true
module = ["_manylinux"]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["packaging._vendor.*"]
ignore_errors = true
follow_imports = "skip"
ignore_missing_imports = true

[tool.ruff]
src = ["src"]
extend-exclude = [
"_vendor"
"src/packaging/licenses/spdx.py"
]

[tool.ruff.lint.isort]
known-third-party = ["packaging._vendor"]

[tool.ruff.lint]
extend-select = [
"B",
Expand Down Expand Up @@ -114,10 +97,3 @@ ignore = [
"ISC001",
"ISC002",
]

[tool.vendoring]
destination = "src/packaging/_vendor/"
requirements = "src/packaging/_vendor/vendor.txt"
namespace = "packaging._vendor"

protected-files = ["__init__.py", "README.rst", "vendor.txt"]
1 change: 0 additions & 1 deletion src/packaging/_spdx.json

This file was deleted.

Empty file removed src/packaging/_vendor/__init__.py
Empty file.
23 changes: 0 additions & 23 deletions src/packaging/_vendor/boolean.py.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/packaging/_vendor/boolean.pyi

This file was deleted.

30 changes: 0 additions & 30 deletions src/packaging/_vendor/boolean/__init__.py

This file was deleted.

Loading

0 comments on commit cec33f1

Please sign in to comment.