mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Modernize packaging
Switch to pyproject.toml packaging, using hatchling. - Replace all uses of setup.py with updated equivalent - BREAKING: Change extra name `amazon_ses` to `amazon-ses`, to comply with Python packaging name normalization - Use hatch custom build hook to freeze version number in readme (previously custom setup.py code) - Move separate requirements for dev, docs, tests into their own requirements.txt files - Fix AnymailImproperlyInstalled to correctly refer to package extra name - Update testing documentation - Update docs readme rendering to match PyPI (and avoid setup.py) - In tox tests, use isolated builds and update pip - Remove AUTHORS.txt (it just referred to GitHub)
This commit is contained in:
43
hatch_build.py
Normal file
43
hatch_build.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Hatch custom build hook that generates dynamic readme.
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
||||
|
||||
|
||||
def freeze_readme_versions(text: str, version: str) -> str:
|
||||
"""
|
||||
Rewrite links in readme text to refer to specific version.
|
||||
(This assumes version X.Y will be tagged "vX.Y" in git.)
|
||||
"""
|
||||
release_tag = f"v{version}"
|
||||
return re.sub(
|
||||
# (?<=...) is "positive lookbehind": must be there, but won't get replaced
|
||||
# GitHub Actions build status: branch=main --> branch=vX.Y.Z:
|
||||
r"(?<=branch[=:])main"
|
||||
# ReadTheDocs links: /stable --> /vX.Y.Z:
|
||||
r"|(?<=/)stable"
|
||||
# ReadTheDocs badge: version=stable --> version=vX.Y.Z:
|
||||
r"|(?<=version=)stable",
|
||||
release_tag,
|
||||
text,
|
||||
)
|
||||
|
||||
|
||||
class CustomMetadataHook(MetadataHookInterface):
|
||||
def update(self, metadata):
|
||||
"""
|
||||
Update the project table's metadata.
|
||||
"""
|
||||
readme_path = Path(self.root) / self.config["readme"]
|
||||
content_type = self.config.get("content-type", "text/x-rst")
|
||||
version = metadata["version"]
|
||||
|
||||
readme_text = readme_path.read_text()
|
||||
readme_text = freeze_readme_versions(readme_text, version)
|
||||
|
||||
metadata["readme"] = {
|
||||
"content-type": content_type,
|
||||
"text": readme_text,
|
||||
}
|
||||
Reference in New Issue
Block a user