From 2ab0707c6a2fab7e5fb74f0c2ccbebfb0865318e Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 28 May 2024 12:00:47 +0100 Subject: [PATCH 1/3] setup.py: use readme_renderer to check rst syntax errors on release --- setup.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6745491b0..b57d07a04 100755 --- a/setup.py +++ b/setup.py @@ -8,6 +8,7 @@ from os.path import isfile, join as pjoin from glob import glob from setuptools import setup, find_packages, Command, Extension from setuptools.command.build_ext import build_ext as _build_ext +from setuptools.errors import SetupError from distutils import log from distutils.util import convert_path import subprocess as sp @@ -33,7 +34,7 @@ if {"bdist_wheel"}.intersection(sys.argv): setup_requires.append("wheel") if {"release"}.intersection(sys.argv): - setup_requires.append("bump2version") + setup_requires.extend(["bump2version", "readme_renderer"]) try: __import__("cython") @@ -266,7 +267,19 @@ class release(Command): raise DistutilsOptionError("--major/--minor are mutually exclusive") self.part = "major" if self.major else "minor" if self.minor else None + def check_long_description_syntax(self): + import readme_renderer.rst + + result = readme_renderer.rst.render(long_description, stream=sys.stderr) + if result is None: + raise SetupError( + "`long_description` has syntax errors in markup" + " and would not be rendered on PyPI." + ) + def run(self): + self.check_long_description_syntax() + if self.part is not None: log.info("bumping '%s' version" % self.part) self.bumpversion(self.part, commit=False) From 159456d269b5fe3f131a9dfbcb8a4a98109bccef Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 31 May 2024 19:18:47 +0100 Subject: [PATCH 2/3] add readme_renderer to dev-requirements.txt --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 4eacf2733..a2eea1b01 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,6 +3,7 @@ tox>=2.5 bump2version>=0.5.6 sphinx>=1.5.5 mypy>=0.782 +readme_renderer[md]>=43.0 # Pin black as each version could change formatting, breaking CI randomly. black==24.4.2 From 162cacb46599710039ea62bb0bb9fa8c3a6c7c00 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 31 May 2024 19:39:35 +0100 Subject: [PATCH 3/3] README: suggest to install dev-requirements.txt before release setup_requires is deprecated, and relying on it to bootstrap the readme_renderer sometimes fails, better to ensure it's already pip installed before running release command --- README.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2274fbdc6..b604ea7ca 100644 --- a/README.rst +++ b/README.rst @@ -232,7 +232,8 @@ How to make a new release 2) Use semantic versioning to decide whether the new release will be a 'major', 'minor' or 'patch' release. It's usually one of the latter two, depending on whether new backward compatible APIs were added, or simply some bugs were fixed. -3) Run ``python setup.py release`` command from the tip of the ``main`` branch. +3) From inside a venv, first do ``pip install -r dev-requirements.txt``, then run + the ``python setup.py release`` command from the tip of the ``main`` branch. By default this bumps the third or 'patch' digit only, unless you pass ``--major`` or ``--minor`` to bump respectively the first or second digit. This bumps the package version string, extracts the changes since the latest