From 18c7b429bed49df3cae82a0de5bc90696e4d29c5 Mon Sep 17 00:00:00 2001 From: Michael Delgado Date: Wed, 18 Sep 2019 20:28:53 -0700 Subject: [PATCH] fix rst issues in pip long_description --- description.py | 23 +++++++++++++++++++++++ setup.py | 9 ++------- 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 description.py diff --git a/description.py b/description.py new file mode 100644 index 0000000..1ff285c --- /dev/null +++ b/description.py @@ -0,0 +1,23 @@ + +with open('README.rst') as readme_file: + readme = readme_file.read() + +with open('HISTORY.rst') as history_file: + history = history_file.read() + +import re + +long_description = re.sub( + r':py:[a-z]+:`([^`]+)`', + r'``\1``', + readme + '\n\n' + history) + +long_description = re.sub( + r':issue:`([^`]+)`', + r'`GH issue #\1 `_', + long_description) + +long_description = re.sub( + r':pull:`([^`]+)`', + r'`GH PR #\1 `_', + long_description) diff --git a/setup.py b/setup.py index d53d274..fa0b952 100644 --- a/setup.py +++ b/setup.py @@ -4,12 +4,7 @@ """The setup script.""" from setuptools import setup, find_packages - -with open('README.rst') as readme_file: - readme = readme_file.read() - -with open('HISTORY.rst') as history_file: - history = history_file.read() +from description import long_description requirements = [ 'Click>=6.0', @@ -31,7 +26,7 @@ name='climate_toolbox', version='0.1.5', description="Tools for climate data wrangling", - long_description=readme + '\n\n' + history, + long_description=long_description, author="Justin Simcock", author_email='jsimcock@rhg.com', url='https://github.com/ClimateImpactLab/climate_toolbox',