Skip to content

Commit 1426364

Browse files
authored
Merge pull request #957 from python-jsonschema/hatch
Modernize the packaging setup via PEP 621 and Hatch.
2 parents f2fb1df + 6a68aa2 commit 1426364

File tree

11 files changed

+215
-164
lines changed

11 files changed

+215
-164
lines changed

.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
ban-relative-imports = true
3+
inline-quotes = "
4+
exclude =
5+
jsonschema/__init__.py
6+
jsonschema/_reflect.py
7+
ignore =
8+
B008, # Barring function calls in default args. Ha, no.
9+
B306, # See https://github.com/PyCQA/flake8-bugbear/issues/131
10+
W503, # (flake8 default) old PEP8 boolean operator line breaks

.github/workflows/ci.yml

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,18 @@ jobs:
8484
toxenv: py310-format_nongpl-build
8585
- name: "3.10"
8686
toxenv: py310-format_nongpl-tests
87-
# Temporarily disabled due to pypa/setuptools#3274
88-
# - name: "3.11.0-alpha - 3.11.0"
89-
# toxenv: py311-noextra-build
90-
# - name: "3.11.0-alpha - 3.11.0"
91-
# toxenv: py311-noextra-tests
92-
# - name: "3.11.0-alpha - 3.11.0"
93-
# toxenv: py311-format-build
94-
# - name: "3.11.0-alpha - 3.11.0"
95-
# toxenv: py311-format-tests
96-
# - name: "3.11.0-alpha - 3.11.0"
97-
# toxenv: py311-format_nongpl-build
98-
# - name: "3.11.0-alpha - 3.11.0"
99-
# toxenv: py311-format_nongpl-tests
87+
- name: "3.11.0-beta - 3.11.0"
88+
toxenv: py311-noextra-build
89+
- name: "3.11.0-beta - 3.11.0"
90+
toxenv: py311-noextra-tests
91+
- name: "3.11.0-beta - 3.11.0"
92+
toxenv: py311-format-build
93+
- name: "3.11.0-beta - 3.11.0"
94+
toxenv: py311-format-tests
95+
- name: "3.11.0-beta - 3.11.0"
96+
toxenv: py311-format_nongpl-build
97+
- name: "3.11.0-beta - 3.11.0"
98+
toxenv: py311-format_nongpl-tests
10099
- name: "3.10"
101100
toxenv: docs-dirhtml
102101
- name: "3.10"
@@ -185,8 +184,6 @@ jobs:
185184
uses: actions/setup-python@v3
186185
with:
187186
python-version: ${{ matrix.python-version.name }}
188-
- name: Ensure we have new enough versions to respect python_version
189-
run: python -m pip install -U pip setuptools
190187
- name: Install dependencies
191188
run: >
192189
sudo apt-get update &&
@@ -199,3 +196,39 @@ jobs:
199196
run: python -m pip install tox
200197
- name: Run tox
201198
run: python -m tox -e "${{ matrix.python-version.toxenv }}"
199+
200+
packaging:
201+
needs: ci
202+
runs-on: ubuntu-latest
203+
204+
steps:
205+
- uses: actions/checkout@v3
206+
with:
207+
fetch-depth: 0
208+
- uses: actions/setup-python@v3
209+
with:
210+
python-version: "3.10"
211+
- name: Install dependencies
212+
run: python -m pip install build
213+
- name: Create packages
214+
run: python -m build .
215+
- uses: actions/upload-artifact@v3
216+
with:
217+
name: dist
218+
path: dist
219+
- name: Publish package
220+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
221+
uses: pypa/gh-action-pypi-publish@master
222+
with:
223+
user: __token__
224+
password: ${{ secrets.pypi_password }}
225+
- name: Create Release Notes
226+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
227+
uses: actions/github-script@v6
228+
with:
229+
github-token: ${{ secrets.GITHUB_TOKEN }}
230+
script: |
231+
await github.request(`POST /repos/${{ github.repository }}/releases`, {
232+
tag_name: "${{ github.ref }}",
233+
generate_release_notes: true
234+
});

.github/workflows/coverage.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
uses: actions/setup-python@v3
1616
with:
1717
python-version: "3.10"
18-
- name: Ensure we have new enough versions to respect python_version
19-
run: python -m pip install -U pip setuptools
2018
- name: Install tox
2119
run: python -m pip install tox
2220
- name: Collect & Upload Coverage

.github/workflows/packaging.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

CONTRIBUTING.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
============================
2+
Contributing to `jsonschema`
3+
============================
4+
5+
Found a bug?
6+
------------
7+
8+
If you suspect you may have found a security-related vulnerability, please follow the instructions in `the security policy <https://github.com/python-jsonschema/jsonschema/blob/main/.github/SECURITY.md>`_.
9+
10+
Otherwise, it is extremely helpful if you first search to see whether your bug has been `previously reported on the Issues tab <https://github.com/python-jsonschema/jsonschema/issues?q=is%3Aissue+is%3Aopen+label%3ABug>`_.
11+
12+
If it doesn't appear to be a known issue, please `file a new one <https://github.com/python-jsonschema/jsonschema/issues/new>`_, and include a **title and clear description**, along with as much relevant information as possible.
13+
Including a *minimal*, *self-sufficient* bit of code (often an instance and schema) is the fastest way to get attention, along with a description of the behavior you expect, and if you're able, a link to where in the specification contains the behavior you're noticing is incorrect.
14+
15+
Pull requests to fix your issue are of course very welcome.
16+
17+
18+
Fixing a Bug?
19+
-------------
20+
21+
Please open a new GitHub pull request with the change, along with new tests.
22+
23+
Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
24+
25+
Continuous integration via GitHub actions should run to indicate whether your change passes both the test suite as well as linters.
26+
Please ensure it passes, or indicate in a comment if you believe it fails spuriously.
27+
28+
29+
Adding New Functionality?
30+
-------------------------
31+
32+
Please discuss any larger changes ahead of time for the sake of your own time!
33+
34+
Improvements are very welcome, but large pull requests, disruptive ones, or backwards incompatible ones, can lead to long back and forth discussions.
35+
36+
You're welcome to suggest a change in an issue and thereby get some initial feedback before embarking on an effort that may not get merged.
37+
38+
39+
Improving the Documentation?
40+
----------------------------
41+
42+
Writing good documentation is challenging both to prioritize and to do well.
43+
44+
Any help you may have would be great, especially if you're a beginner who's struggled to understand a part of the library.
45+
46+
Documentation is written in `Sphinx-flavored reStructuredText <https://www.sphinx-doc.org>`_, so you'll want to familiarize yourself a bit with Sphinx.
47+
48+
Feel free to file issues or pull requests.
49+
50+
51+
Have a Question?
52+
----------------
53+
54+
Please do not use the issue tracker for questions, it's reserved for things believed to be bugs, or new functionality.
55+
56+
There is a `discussions tab <https://github.com/python-jsonschema/jsonschema/discussions>`_ where general questions can be asked.
57+
58+
Answers on it are best-effort.
59+
60+
Any help you can offer to answer others' questions is of course very welcome as well.

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ schemas can be found there.
125125
Otherwise, asking questions on Stack Overflow is another means of
126126
getting help if you're stuck.
127127

128-
Contributing
129-
------------
128+
129+
About
130+
-----
130131

131132
I'm Julian Berman.
132133

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def entire_domain(host):
239239

240240

241241
linkcheck_ignore = [
242+
entire_domain("img.shields.io"),
242243
"https://github.com/python-jsonschema/jsonschema/actions",
243244
"https://github.com/python-jsonschema/jsonschema/workflows/CI/badge.svg",
244245
]

docs/validate.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ to validate. Their names can be viewed by inspecting the
205205
`FormatChecker.checkers` attribute. Certain checkers will only be
206206
available if an appropriate package is available for use. The easiest way to
207207
ensure you have what is needed is to install ``jsonschema`` using the
208-
``format`` or ``format_nongpl`` setuptools extra -- i.e.
208+
``format`` or ``format_nongpl`` collection of optional dependencies -- e.g.
209209

210210
.. code-block:: sh
211211

pyproject.toml

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,97 @@
11
[build-system]
2-
requires = [
3-
# The minimum setuptools version is specific to the PEP 517 backend,
4-
# and may be stricter than the version required in `setup.py`
5-
"setuptools>=40.6.0",
6-
"setuptools_scm[toml]>=3.4",
7-
"wheel",
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[tool.hatch.version]
6+
source = "vcs"
7+
8+
[project]
9+
name = "jsonschema"
10+
description = "An implementation of JSON Schema validation for Python"
11+
readme = "README.rst"
12+
requires-python = ">=3.7"
13+
license = {text = "MIT"}
14+
keywords = ["validation", "data validation", "jsonschema", "json"]
15+
authors = [
16+
{email = "[email protected]"},
17+
{name = "Julian Berman"},
18+
]
19+
classifiers = [
20+
"Development Status :: 5 - Production/Stable",
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: MIT License",
23+
"Operating System :: OS Independent",
24+
"Programming Language :: Python",
25+
"Programming Language :: Python :: 3.7",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: Implementation :: CPython",
31+
"Programming Language :: Python :: Implementation :: PyPy",
32+
]
33+
dynamic = ["version"]
34+
35+
dependencies = [
36+
"attrs>=17.4.0",
37+
"pyrsistent>=0.14.0,!=0.17.0,!=0.17.1,!=0.17.2",
38+
39+
"importlib_metadata;python_version<'3.8'",
40+
"typing_extensions;python_version<'3.8'",
41+
"importlib_resources>=1.4.0;python_version<'3.9'",
42+
]
43+
44+
[project.optional-dependencies]
45+
format = [
46+
"fqdn",
47+
"idna",
48+
"isoduration",
49+
"jsonpointer>1.13",
50+
"rfc3339-validator",
51+
"rfc3987",
52+
"uri_template",
53+
"webcolors>=1.11",
54+
]
55+
format_nongpl = [
56+
"fqdn",
57+
"idna",
58+
"isoduration",
59+
"jsonpointer>1.13",
60+
"rfc3339-validator",
61+
"rfc3986-validator>0.1.0",
62+
"uri_template",
63+
"webcolors>=1.11",
864
]
9-
build-backend = "setuptools.build_meta"
65+
66+
[project.scripts]
67+
jsonschema = "jsonschema.cli:main"
68+
69+
[project.urls]
70+
homepage = "https://github.com/python-jsonschema/jsonschema"
71+
documentation = "https://python-jsonschema.readthedocs.io/"
72+
issues = "https://github.com/python-jsonschema/jsonschema/issues/"
73+
funding = "https://github.com/sponsors/Julian"
74+
tidelift = "https://tidelift.com/subscription/pkg/pypi-jsonschema?utm_source=pypi-jsonschema&utm_medium=referral&utm_campaign=pypi-link"
75+
changelog = "https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst"
76+
source = "https://github.com/python-jsonschema/jsonschema"
1077

1178
[tool.isort]
1279
from_first = true
1380
include_trailing_comma = true
1481
multi_line_output = 3
1582

16-
[tool.setuptools_scm]
83+
[tool.mypy]
84+
ignore_missing_imports = true
85+
86+
[tool.pydocstyle]
87+
match = "(?!(test_|_|compat|cli)).*\\.py" # see PyCQA/pydocstyle#323
88+
add-select = [
89+
"D410", # Trailing whitespace plz
90+
]
91+
add-ignore = [
92+
"D107", # Hah, no
93+
"D200", # 1-line docstrings don't need to be on one line
94+
"D202", # One line is fine.
95+
"D412", # Trailing whitespace plz
96+
"D413", # No trailing whitespace plz
97+
]

0 commit comments

Comments
 (0)