Skip to content

Commit 6060197

Browse files
authored
Convert from setup.cfg to pyproject.toml (#467)
* Convert setup.cfg to pyproject.toml * Update workflow tools for transition to pyproject * Note pyproject.toml conversion in changelog
1 parent 2ad01f7 commit 6060197

File tree

8 files changed

+102
-98
lines changed

8 files changed

+102
-98
lines changed

.github/workflows/build.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
cache: "pip"
2929
cache-dependency-path: |
3030
.github/workflows/build.yaml
31-
setup.cfg
31+
pyproject.toml
3232
tox.ini
3333
cachedate.txt
3434
@@ -49,12 +49,12 @@ jobs:
4949
- name: build and unpack sdist
5050
run: |
5151
python -m build --sdist
52-
version="$(grep '^version' setup.cfg | cut -d '=' -f2 | tr -d ' ')"
52+
version="$(grep '^version' pyproject.toml | head -n1 | cut -d'"' -f2)"
5353
cd dist
5454
tar -xzf "check_jsonschema-${version}.tar.gz"
5555
- name: test
5656
run: |
57-
version="$(grep '^version' setup.cfg | cut -d '=' -f2 | tr -d ' ')"
57+
version="$(grep '^version' pyproject.toml | head -n1 | cut -d'"' -f2)"
5858
cd "dist/check_jsonschema-${version}"
5959
python -m tox run -m ci
6060
@@ -79,7 +79,7 @@ jobs:
7979
cache: "pip"
8080
cache-dependency-path: |
8181
.github/workflows/build.yaml
82-
setup.cfg
82+
pyproject.toml
8383
tox.ini
8484
cachedate.txt
8585
@@ -93,7 +93,7 @@ jobs:
9393
tox
9494
os=${{ runner.os }}
9595
python=${{ steps.setup-python.outputs.python-version }}
96-
hash=${{ hashFiles('.github/workflows/build.yaml', 'setup.cfg', 'tox.ini', 'cachedate.txt') }}
96+
hash=${{ hashFiles('.github/workflows/build.yaml', 'pyproject.toml', 'tox.ini', 'cachedate.txt') }}
9797
9898
- name: test
9999
run: |
@@ -141,7 +141,7 @@ jobs:
141141
cache: "pip"
142142
cache-dependency-path: |
143143
.github/workflows/build.yaml
144-
setup.cfg
144+
pyproject.toml
145145
tox.ini
146146
cachedate.txt
147147
@@ -169,7 +169,7 @@ jobs:
169169
cache: "pip"
170170
cache-dependency-path: |
171171
.github/workflows/build.yaml
172-
setup.cfg
172+
pyproject.toml
173173
tox.ini
174174
cachedate.txt
175175

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ repos:
2626
rev: 7.1.0
2727
hooks:
2828
- id: flake8
29-
args: ['--config', '.flake8']
3029
additional_dependencies:
3130
- 'flake8-bugbear==24.4.26'
3231
- 'flake8-typing-as-t==0.0.3'

CHANGELOG.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Unreleased
99
----------
1010

1111
.. vendor-insert-here
12+
- Convert from ``setup.cfg`` to ``pyproject.toml`` for python package metadata
1213

1314
- Update vendored schemas (2024-07-28)
1415

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PKG_VERSION=$(shell grep '^version' setup.cfg | cut -d '=' -f2 | tr -d ' ')
1+
PKG_VERSION=$(shell grep '^version' pyproject.toml | head -n1 | cut -d '"' -f2)
22

33
.PHONY: lint test vendor-schemas generate-hooks release showvars
44
lint:

pyproject.toml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[build-system]
2+
requires = ["setuptools>=61.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "check-jsonschema"
7+
version = "0.29.1"
8+
description = "A jsonschema CLI and pre-commit hook"
9+
authors = [
10+
{ name = "Stephen Rosen", email = "[email protected]" },
11+
]
12+
classifiers = [
13+
"Development Status :: 4 - Beta",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: Apache Software License",
16+
"Programming Language :: Python :: 3",
17+
]
18+
requires-python = ">=3.8"
19+
dependencies = [
20+
'importlib-resources>=1.4.0;python_version<"3.9"',
21+
'tomli>=2.0;python_version<"3.11"',
22+
"ruamel.yaml==0.18.6",
23+
"jsonschema>=4.18.0,<5.0",
24+
"regress>=0.4.0",
25+
"requests<3.0",
26+
"click>=8,<9",
27+
]
28+
29+
[project.readme]
30+
file = "README.md"
31+
content-type = "text/markdown"
32+
33+
[project.urls]
34+
Homepage = "https://github.com/python-jsonschema/check-jsonschema"
35+
36+
[project.optional-dependencies]
37+
dev = [
38+
"pytest<9",
39+
'click-type-test==0.0.7;python_version>="3.10"',
40+
"coverage<8",
41+
"pytest-xdist<4",
42+
"responses==0.25.3",
43+
]
44+
docs = [
45+
"sphinx<8",
46+
"sphinx-issues<5",
47+
"furo==2024.7.18",
48+
]
49+
50+
[project.scripts]
51+
check-jsonschema = "check_jsonschema:main"
52+
53+
[tool.setuptools]
54+
include-package-data = true
55+
56+
[tool.setuptools.packages.find]
57+
where = ["src"]
58+
namespaces = false
59+
60+
[tool.isort]
61+
profile = "black"
62+
63+
[tool.mypy]
64+
# strict = true # TODO: enable
65+
disallow_untyped_defs = true
66+
ignore_missing_imports = true
67+
warn_unreachable = true
68+
warn_no_return = true
69+
70+
[tool.pytest.ini_options]
71+
filterwarnings = [
72+
"error",
73+
# dateutil has a Python 3.12 compatibility issue.
74+
'ignore:datetime\.datetime\.utcfromtimestamp\(\) is deprecated:DeprecationWarning',
75+
]

scripts/bump-version.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55

66
def get_old_version():
7-
with open("setup.cfg") as fp:
7+
with open("pyproject.toml") as fp:
88
content = fp.read()
9-
match = re.search(r"^version = (\d+\.\d+\.\d+)$", content, flags=re.MULTILINE)
9+
match = re.search(r'^version = "(\d+\.\d+\.\d+)"$', content, flags=re.MULTILINE)
1010
assert match
1111
return match.group(1)
1212

1313

14-
def replace_version(filename, prefix, old_version, new_version):
14+
def replace_version(filename, formatstr, old_version, new_version):
1515
print(f"updating {filename}")
1616
with open(filename) as fp:
1717
content = fp.read()
18-
old_str = prefix + old_version
19-
new_str = prefix + new_version
18+
old_str = formatstr.format(old_version)
19+
new_str = formatstr.format(new_version)
2020
content = content.replace(old_str, new_str)
2121
with open(filename, "w") as fp:
2222
fp.write(content)
@@ -68,10 +68,10 @@ def main():
6868
print(f"old = {old_version}, new = {new_version}")
6969
comparse_versions(old_version, new_version)
7070

71-
replace_version("setup.cfg", "version = ", old_version, new_version)
72-
replace_version("README.md", "rev: ", old_version, new_version)
73-
replace_version("docs/precommit_usage.rst", "rev: ", old_version, new_version)
74-
replace_version("docs/optional_parsers.rst", "rev: ", old_version, new_version)
71+
replace_version("pyproject.toml", 'version = "{}"', old_version, new_version)
72+
replace_version("README.md", "rev: {}", old_version, new_version)
73+
replace_version("docs/precommit_usage.rst", "rev: {}", old_version, new_version)
74+
replace_version("docs/optional_parsers.rst", "rev: {}", old_version, new_version)
7575
update_changelog(new_version)
7676

7777

scripts/set-dev-version.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55

66
def get_old_version():
7-
with open("setup.cfg") as fp:
7+
with open("pyproject.toml") as fp:
88
content = fp.read()
9-
match = re.search(r"^version = (\d+\.\d+\.\d+)$", content, flags=re.MULTILINE)
9+
match = re.search(r'^version = "(\d+\.\d+\.\d+)"$', content, flags=re.MULTILINE)
1010
assert match
1111
return match.group(1)
1212

1313

14-
def replace_version(old_version, new_version):
15-
print(f"updating setup.cfg version to {new_version}")
16-
with open("setup.cfg") as fp:
14+
def replace_version(filename, formatstr, old_version, new_version):
15+
print(f"updating {filename}")
16+
with open(filename) as fp:
1717
content = fp.read()
18-
old_str = f"version = {old_version}"
19-
new_str = f"version = {new_version}"
18+
old_str = formatstr.format(old_version)
19+
new_str = formatstr.format(new_version)
2020
content = content.replace(old_str, new_str)
21-
with open("setup.cfg", "w") as fp:
21+
with open(filename, "w") as fp:
2222
fp.write(content)
2323

2424

@@ -32,7 +32,7 @@ def main():
3232
old_version = get_old_version()
3333
new_version = old_version + f".dev{args.number}"
3434

35-
replace_version(old_version, new_version)
35+
replace_version("pyproject.toml", 'version = "{}"', old_version, new_version)
3636
print("done")
3737

3838

setup.cfg

-71
This file was deleted.

0 commit comments

Comments
 (0)