Skip to content

Commit 6f020a3

Browse files
authored
Merge pull request #62 from jwodder/pep639
Update for PEP 639
2 parents aec601f + b74041a commit 6f020a3

File tree

53 files changed

+119
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+119
-105
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
In Development
22
--------------
3-
- Update twine dependency to 6.0
3+
- Update twine dependency to 6.1
44
- `pyrepo release`: Allow using `--date` when there are no previous tags
5+
- Templates:
6+
- `pyproject.toml`:
7+
- Use final PEP 639 syntax for `license-files`
8+
- Remove license classifier to comply with PEP 639
59

610
v2024.11.29
711
-----------

migrations/0006-pep639.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env pipx run
2+
# /// script
3+
# requires-python = ">=3.9"
4+
# dependencies = [
5+
# "click ~= 8.0",
6+
# "in-place ~= 1.0",
7+
# ]
8+
# ///
9+
10+
from __future__ import annotations
11+
import os
12+
from pathlib import Path
13+
import shlex
14+
import subprocess
15+
import sys
16+
from typing import Any
17+
import click
18+
from in_place import InPlace
19+
20+
21+
@click.command()
22+
@click.option("--git/--no-git", default=True)
23+
@click.argument(
24+
"dirpath",
25+
type=click.Path(exists=True, file_okay=False, path_type=Path),
26+
default=os.curdir,
27+
)
28+
def main(dirpath: Path, git: bool) -> None:
29+
update_pyproject(dirpath)
30+
if git:
31+
log("Committing ...")
32+
runcmd(
33+
"git", "commit", "-m", "Update for PEP 639", "pyproject.toml", cwd=dirpath
34+
)
35+
36+
37+
def update_pyproject(dirpath: Path) -> None:
38+
log("Updating pyproject.toml ...")
39+
with InPlace(dirpath / "pyproject.toml", encoding="utf-8") as fp:
40+
for line in fp:
41+
if line.startswith("license-files ="):
42+
line = 'license-files = ["LICENSE"]\n'
43+
elif line.strip() == '"License :: OSI Approved :: MIT License",':
44+
continue
45+
print(line, end="", file=fp)
46+
47+
48+
def runcmd(*args: str | Path, **kwargs: Any) -> None:
49+
argstrs = [str(a) for a in args]
50+
click.secho("+" + shlex.join(argstrs), err=True, fg="green")
51+
r = subprocess.run(argstrs, **kwargs)
52+
if r.returncode != 0:
53+
sys.exit(r.returncode)
54+
55+
56+
def log(msg: str) -> None:
57+
click.secho(msg, err=True, bold=True)
58+
59+
60+
if __name__ == "__main__":
61+
main()

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Python repository templater & releaser"
99
readme = "README.rst"
1010
requires-python = ">=3.10"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -31,7 +31,6 @@ classifiers = [
3131
"Programming Language :: Python :: 3.12",
3232
"Programming Language :: Python :: 3.13",
3333
"Programming Language :: Python :: Implementation :: CPython",
34-
"License :: OSI Approved :: MIT License",
3534
"Environment :: Console",
3635
"Intended Audience :: Developers",
3736
"Topic :: Software Development :: Code Generators",
@@ -56,12 +55,12 @@ dependencies = [
5655
"Jinja2 ~= 3.0",
5756
"lineinfile ~= 0.1",
5857
"linesep ~= 0.3",
59-
"packaging >= 17.1",
58+
"packaging >= 24.2",
6059
"pynacl ~= 1.4",
6160
"pyversion-info ~= 1.0",
6261
"ruamel.yaml >= 0.15, < 1.0",
6362
"tomli >= 1.2, < 3.0; python_version < '3.11'",
64-
"twine ~= 6.0",
63+
"twine ~= 6.1",
6564
"uritemplate ~= 4.1",
6665
# Running `python -m hatch ...` for inspection purposes seems to cause
6766
# Hatch to use the current environment rather than one of its managed

src/pyrepo/templates/pyproject.toml.j2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description = "{{short_description}}"
1313
readme = "README.rst"
1414
requires-python = "{{python_requires}}"
1515
license = "MIT"
16-
license-files = { paths = ["LICENSE"] }
16+
license-files = ["LICENSE"]
1717
authors = [
1818
{ name = "{{author}}", email = "{{author_email}}" }
1919
]
@@ -38,7 +38,6 @@ classifiers = [
3838
{% if supports_pypy %}
3939
"Programming Language :: Python :: Implementation :: PyPy",
4040
{% endif %}
41-
"License :: OSI Approved :: MIT License",
4241
###
4342
{% if has_typing %}
4443
"Typing :: Typed",

test/data/pyrepo_init/bothreq-overlap/after/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A project"
99
readme = "README.rst"
1010
requires-python = ">=3.5"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -27,7 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.8",
2828
"Programming Language :: Python :: Implementation :: CPython",
2929
"Programming Language :: Python :: Implementation :: PyPy",
30-
"License :: OSI Approved :: MIT License",
3130
###
3231
]
3332

test/data/pyrepo_init/bothreq/after/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A project"
99
readme = "README.rst"
1010
requires-python = ">=3.5"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -27,7 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.8",
2828
"Programming Language :: Python :: Implementation :: CPython",
2929
"Programming Language :: Python :: Implementation :: PyPy",
30-
"License :: OSI Approved :: MIT License",
3130
###
3231
]
3332

test/data/pyrepo_init/coding-comment/after/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A project"
99
readme = "README.rst"
1010
requires-python = ">=3.5"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -27,7 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.8",
2828
"Programming Language :: Python :: Implementation :: CPython",
2929
"Programming Language :: Python :: Implementation :: PyPy",
30-
"License :: OSI Approved :: MIT License",
3130
###
3231
]
3332

test/data/pyrepo_init/command-flat/after/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A project"
99
readme = "README.rst"
1010
requires-python = ">=3.5"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -27,7 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.8",
2828
"Programming Language :: Python :: Implementation :: CPython",
2929
"Programming Language :: Python :: Implementation :: PyPy",
30-
"License :: OSI Approved :: MIT License",
3130
###
3231
]
3332

test/data/pyrepo_init/command-noflat-req/after/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A project"
99
readme = "README.rst"
1010
requires-python = ">=3.5"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -27,7 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.8",
2828
"Programming Language :: Python :: Implementation :: CPython",
2929
"Programming Language :: Python :: Implementation :: PyPy",
30-
"License :: OSI Approved :: MIT License",
3130
###
3231
]
3332

test/data/pyrepo_init/command-noflat/after/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A project"
99
readme = "README.rst"
1010
requires-python = ">=3.5"
1111
license = "MIT"
12-
license-files = { paths = ["LICENSE"] }
12+
license-files = ["LICENSE"]
1313
authors = [
1414
{ name = "John Thorvald Wodder II", email = "[email protected]" }
1515
]
@@ -27,7 +27,6 @@ classifiers = [
2727
"Programming Language :: Python :: 3.8",
2828
"Programming Language :: Python :: Implementation :: CPython",
2929
"Programming Language :: Python :: Implementation :: PyPy",
30-
"License :: OSI Approved :: MIT License",
3130
###
3231
]
3332

0 commit comments

Comments
 (0)