Skip to content

Commit

Permalink
Use local schemas to define validation for pyproject.toml (#4364)
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri authored Aug 8, 2024
2 parents 46fe699 + d6601ba commit 2a46d2d
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 13 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ recursive-include newsfragments *
include *.py
include *.rst
include MANIFEST.in
include LICENSE
global-include LICEN[CS]E* COPYING* NOTICE* AUTHORS*
include launcher.c
include msvc-build-launcher.cmd
include mypy.ini
include pytest.ini
include tox.ini
include setuptools/tests/config/setupcfg_examples.txt
include setuptools/config/*.schema.json
global-exclude *.py[cod] __pycache__
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
here = os.path.dirname(__file__)


package_data = dict(
setuptools=['script (dev).tmpl', 'script.tmpl', 'site-patch.py'],
)
package_data = {
"": ["LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*"],
"setuptools": ['script (dev).tmpl', 'script.tmpl', 'site-patch.py'],
}

force_windows_specific_files = os.environ.get(
"SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES", "1"
Expand Down
10 changes: 10 additions & 0 deletions setuptools/config/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The following files include code from opensource projects
(either as direct copies or modified versions):

- `setuptools.schema.json`, `distutils.schema.json`:
- project: `validate-pyproject` - licensed under MPL-2.0
(https://github.com/abravalheri/validate-pyproject):

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
2 changes: 1 addition & 1 deletion setuptools/config/_validate_pyproject/NOTICE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The code contained in this directory was automatically generated using the
following command:

python -m validate_pyproject.pre_compile --output-dir=setuptools/config/_validate_pyproject --enable-plugins setuptools distutils --very-verbose
python -m validate_pyproject.pre_compile --output-dir=setuptools/config/_validate_pyproject --enable-plugins setuptools distutils --very-verbose -t distutils=setuptools/config/distutils.schema.json -t setuptools=setuptools/config/setuptools.schema.json

Please avoid changing it manually.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# *** PLEASE DO NOT MODIFY DIRECTLY: Automatically generated code ***


VERSION = "2.19.1"
VERSION = "2.20.0"
from decimal import Decimal
import re
from .fastjsonschema_exceptions import JsonSchemaValueException
Expand Down
2 changes: 1 addition & 1 deletion setuptools/config/_validate_pyproject/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def pep508(value: str) -> bool:
"""
try:
_req.Requirement(value)
return True
except _req.InvalidRequirement:
return False
return True

except ImportError: # pragma: no cover
_logger.warning(
Expand Down
26 changes: 26 additions & 0 deletions setuptools/config/distutils.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",

"$id": "https://setuptools.pypa.io/en/latest/deprecated/distutils/configfile.html",
"title": "``tool.distutils`` table",
"$$description": [
"**EXPERIMENTAL** (NOT OFFICIALLY SUPPORTED): Use ``tool.distutils``",
"subtables to configure arguments for ``distutils`` commands.",
"Originally, ``distutils`` allowed developers to configure arguments for",
"``setup.py`` commands via `distutils configuration files",
"<https://setuptools.pypa.io/en/latest/deprecated/distutils/configfile.html>`_.",
"See also `the old Python docs <https://docs.python.org/3.11/install/>_`."
],

"type": "object",
"properties": {
"global": {
"type": "object",
"description": "Global options applied to all ``distutils`` commands"
}
},
"patternProperties": {
".+": {"type": "object"}
},
"$comment": "TODO: Is there a practical way of making this schema more specific?"
}
Loading

0 comments on commit 2a46d2d

Please sign in to comment.