Re-enable support for installing git archives

setuptools_scm 7 includes git archive support. hatch-vcs
currently requires a minimium of 6.4, ensure 7 is installed.
This commit is contained in:
Chris Mayo 2023-01-17 19:26:24 +00:00
parent ec9386d002
commit 98d32a11a7
5 changed files with 20 additions and 3 deletions

4
.git_archival.txt Normal file
View file

@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$

1
.gitattributes vendored
View file

@ -1,2 +1,3 @@
.git_archival.txt export-subst
.gitattributes export-ignore
.gitignore export-ignore

View file

@ -51,8 +51,6 @@ First, if you want application translations:
Then:
``pip3 install git+https://github.com/linkchecker/linkchecker.git``
N.B. git archive's cannot be used.
.. _pip: https://pypi.org/project/pip/
Setup for Windows

View file

@ -28,8 +28,9 @@ dependencies = [
[build-system]
requires = [
"hatchling>=1.8.0",
"hatchling >= 1.8.0",
"hatch-vcs",
"setuptools-scm >= 7.0.5",
]
build-backend = "hatchling.build"

View file

@ -15,6 +15,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from pathlib import Path
import re
import shutil
import subprocess
@ -47,6 +48,18 @@ class CustomBuildHook(BuildHookInterface):
if Path(*RELEASE_PY).is_file():
self.app.display_warning("_release.py already exists")
return
try:
git_archival = Path(".git_archival.txt").read_text()
except FileNotFoundError:
self.app.display_warning(".git_archival.txt does not exist")
else:
rematch = re.search(r"node-date: ((\d{4})-\d{2}-\d{2})", git_archival)
if rematch:
committer_date = rematch.group(1)
committer_year = rematch.group(2)
else:
self.app.display_warning("node-date not substituted")
else:
if cp and cp.stdout:
committer_date = cp.stdout.strip()