From 699008ddc207c28d8f39234c112e6e3b8859c1a2 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 7 Dec 2021 19:44:20 +0000 Subject: [PATCH 1/3] Set release date from HEAD Match the version reported using setuptools_scm. Use the same git command as setuptools_scm uses for node_date. --- .gitignore | 1 + MANIFEST.in | 1 + setup.cfg | 4 +++- setup.py | 36 +++++++++++++++++++++++------------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index afb63af6..7ec80d87 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ /coverage MANIFEST _LinkChecker_configdata.py +_release_date Changelog.linkchecker* /*-stamp /*-stamp-* diff --git a/MANIFEST.in b/MANIFEST.in index 9572893e..93a244c9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -10,6 +10,7 @@ include install-rpm.sh include .project include .pydevproject include .yamllint +include _release_date recursive-include cgi-bin \ *.css \ diff --git a/setup.cfg b/setup.cfg index eb9c984a..c47c31d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,9 @@ universal = 0 [check-manifest] ignore-bad-ideas = *.mo -ignore = *.rej +ignore = + *.rej + _release_date [flake8] filename = diff --git a/setup.py b/setup.py index f912d19c..c369f347 100755 --- a/setup.py +++ b/setup.py @@ -30,8 +30,8 @@ import sys if sys.version_info < (3, 6, 0, "final", 0): raise SystemExit("This program requires Python 3.6 or later.") import os -import re import stat +import subprocess from pathlib import Path # import Distutils stuff @@ -40,6 +40,7 @@ from distutils.command.install_lib import install_lib from distutils.command.build import build from distutils.command.clean import clean from distutils.command.install_data import install_data +from setuptools.command.sdist import sdist from distutils.dir_util import remove_tree from distutils.file_util import write_file from distutils import util, log @@ -57,6 +58,8 @@ else: AppName = "LinkChecker" Description = "check links in web documents or full websites" +RELEASE_DATE_FILE = "_release_date" + def get_long_description(): """Try to read long description from README.rst.""" @@ -83,19 +86,19 @@ def cnormpath(path): return path -release_ro = re.compile(r"\(released (.+)\)") - - -def get_release_date(): - """Parse and return relase date as string from doc/changelog.txt.""" - fname = os.path.join("doc", "changelog.txt") +def get_release_date(for_sdist=False): + """Return release date as a string from the most recent commit.""" release_date = "unknown" - with open(fname) as fd: - # the release date is on the first line - line = fd.readline() - mo = release_ro.search(line) - if mo: - release_date = mo.groups(1) + # need git >= 2.25.0 for %cs + cp = subprocess.run(["git", "log", "-n 1", "HEAD", "--format=%cI"], + stdout=subprocess.PIPE, universal_newlines=True) + if cp.stdout: + release_date = cp.stdout.split("T")[0] + elif not for_sdist: + try: + release_date = Path(RELEASE_DATE_FILE).read_text() + except FileNotFoundError: + pass return release_date @@ -104,6 +107,12 @@ def get_portable(): return os.environ.get("LINKCHECKER_PORTABLE", "0") +class MySdist(sdist): + def run(self): + Path(RELEASE_DATE_FILE).write_text(get_release_date(for_sdist=True)) + super().run() + + class MyBuild(build): """Custom build with translation compilation""" @@ -350,6 +359,7 @@ setup( long_description_content_type="text/x-rst", distclass=MyDistribution, cmdclass={ + "sdist": MySdist, "build": MyBuild, "install_lib": MyInstallLib, "install_data": MyInstallData, From 7eb4cc7a66c0ecad27a7f6970fdc0e4be818e3a6 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 7 Dec 2021 19:44:20 +0000 Subject: [PATCH 2/3] Fix check warning that MANIFEST.in is not compatible with Windows --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 93a244c9..1b7e7a88 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -82,4 +82,4 @@ recursive-include windows \ *.pfx \ *.pvk -prune .github/ +prune .github From 9dd39ef2642c5f3e93e11a44e04170104e786f50 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 7 Dec 2021 19:44:20 +0000 Subject: [PATCH 3/3] Remove *.mo from ignore-bad-ideas .mo files have not been distributed since: e297b1a47 ("Stop including binary translation catalogs in the source", 2021-11-22) --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index c47c31d4..3e2c0772 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,6 @@ python = python universal = 0 [check-manifest] -ignore-bad-ideas = *.mo ignore = *.rej _release_date