From 7d7798560167b8bbc4d9c7de1ad93bb900194cd9 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 29 Jan 2024 19:50:14 +0100 Subject: [PATCH] setup.py: move long_desc_from_readme definition to here --- setup.py | 17 ++++++++++++++++- setup_docs.py | 14 -------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index c59f54e3a..5174617b6 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ # borgbackup - main setup code (see also setup.cfg and other setup_*.py files) import os +import re import sys from collections import defaultdict from glob import glob @@ -253,4 +254,18 @@ def lib_ext_kwargs(pc, prefix_env_var, lib_name, lib_pkg_name, pc_version, lib_s ext_modules = cythonize(ext_modules, **cython_opts) -setup(cmdclass=cmdclass, ext_modules=ext_modules, long_description=setup_docs.long_desc_from_readme()) +def long_desc_from_readme(): + with open("README.rst") as fd: + long_description = fd.read() + # remove header, but have one \n before first headline + start = long_description.find("What is BorgBackup?") + assert start >= 0 + long_description = "\n" + long_description[start:] + # remove badges + long_description = re.compile(r"^\.\. start-badges.*^\.\. end-badges", re.M | re.S).sub("", long_description) + # remove unknown directives + long_description = re.compile(r"^\.\. highlight:: \w+$", re.M).sub("", long_description) + return long_description + + +setup(cmdclass=cmdclass, ext_modules=ext_modules, long_description=long_desc_from_readme()) diff --git a/setup_docs.py b/setup_docs.py index 0861140e2..b0777be4c 100644 --- a/setup_docs.py +++ b/setup_docs.py @@ -12,20 +12,6 @@ from setuptools import Command -def long_desc_from_readme(): - with open("README.rst") as fd: - long_description = fd.read() - # remove header, but have one \n before first headline - start = long_description.find("What is BorgBackup?") - assert start >= 0 - long_description = "\n" + long_description[start:] - # remove badges - long_description = re.compile(r"^\.\. start-badges.*^\.\. end-badges", re.M | re.S).sub("", long_description) - # remove unknown directives - long_description = re.compile(r"^\.\. highlight:: \w+$", re.M).sub("", long_description) - return long_description - - def format_metavar(option): if option.nargs in ("*", "..."): return "[%s...]" % option.metavar