Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for PEP 639 #62

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
In Development
--------------
- Update twine dependency to 6.0
- Update twine dependency to 6.1
- `pyrepo release`: Allow using `--date` when there are no previous tags
- Templates:
- `pyproject.toml`:
- Use final PEP 639 syntax for `license-files`
- Remove license classifier to comply with PEP 639

v2024.11.29
-----------
Expand Down
61 changes: 61 additions & 0 deletions migrations/0006-pep639.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env pipx run
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "click ~= 8.0",
# "in-place ~= 1.0",
# ]
# ///

from __future__ import annotations
import os
from pathlib import Path
import shlex
import subprocess
import sys
from typing import Any
import click
from in_place import InPlace


@click.command()
@click.option("--git/--no-git", default=True)
@click.argument(
"dirpath",
type=click.Path(exists=True, file_okay=False, path_type=Path),
default=os.curdir,
)
def main(dirpath: Path, git: bool) -> None:
update_pyproject(dirpath)
if git:
log("Committing ...")
runcmd(
"git", "commit", "-m", "Update for PEP 639", "pyproject.toml", cwd=dirpath
)


def update_pyproject(dirpath: Path) -> None:
log("Updating pyproject.toml ...")
with InPlace(dirpath / "pyproject.toml", encoding="utf-8") as fp:
for line in fp:
if line.startswith("license-files ="):
line = 'license-files = ["LICENSE"]\n'
elif line.strip() == '"License :: OSI Approved :: MIT License",':
continue
print(line, end="", file=fp)


def runcmd(*args: str | Path, **kwargs: Any) -> None:
argstrs = [str(a) for a in args]
click.secho("+" + shlex.join(argstrs), err=True, fg="green")
r = subprocess.run(argstrs, **kwargs)
if r.returncode != 0:
sys.exit(r.returncode)


def log(msg: str) -> None:
click.secho(msg, err=True, bold=True)


if __name__ == "__main__":
main()
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Python repository templater & releaser"
readme = "README.rst"
requires-python = ">=3.10"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -31,7 +31,6 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"License :: OSI Approved :: MIT License",
"Environment :: Console",
"Intended Audience :: Developers",
"Topic :: Software Development :: Code Generators",
Expand All @@ -56,12 +55,12 @@ dependencies = [
"Jinja2 ~= 3.0",
"lineinfile ~= 0.1",
"linesep ~= 0.3",
"packaging >= 17.1",
"packaging >= 24.2",
"pynacl ~= 1.4",
"pyversion-info ~= 1.0",
"ruamel.yaml >= 0.15, < 1.0",
"tomli >= 1.2, < 3.0; python_version < '3.11'",
"twine ~= 6.0",
"twine ~= 6.1",
"uritemplate ~= 4.1",
# Running `python -m hatch ...` for inspection purposes seems to cause
# Hatch to use the current environment rather than one of its managed
Expand Down
3 changes: 1 addition & 2 deletions src/pyrepo/templates/pyproject.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = "{{short_description}}"
readme = "README.rst"
requires-python = "{{python_requires}}"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "{{author}}", email = "{{author_email}}" }
]
Expand All @@ -38,7 +38,6 @@ classifiers = [
{% if supports_pypy %}
"Programming Language :: Python :: Implementation :: PyPy",
{% endif %}
"License :: OSI Approved :: MIT License",
###
{% if has_typing %}
"Typing :: Typed",
Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/bothreq-overlap/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/bothreq/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/coding-comment/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/command-flat/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/command-noflat/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/docs-tests/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/docs/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/fetch-github-user/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/flat-ci/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/flat-doctests/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">= 3.6"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -26,7 +26,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = "~= 3.6"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -26,7 +26,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
3 changes: 1 addition & 2 deletions test/data/pyrepo_init/flat-noreq/after/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = ">=3.5"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A project"
readme = "README.rst"
requires-python = "~= 3.6"
license = "MIT"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
authors = [
{ name = "John Thorvald Wodder II", email = "[email protected]" }
]
Expand All @@ -26,7 +26,6 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
###
]

Expand Down
Loading
Loading