From 9952eaad84863e8321a4a814883d8027f37c5295 Mon Sep 17 00:00:00 2001 From: Ford Date: Tue, 26 Sep 2017 17:04:57 -0700 Subject: [PATCH] Use pandoc to convert markdown to rst (#2) --- .travis.yml | 6 ++++++ setup.py | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8006610..2b78928 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: install: - pip install -r requirements.txt +- pip install pypandoc script: - pycodestyle . @@ -20,3 +21,8 @@ deploy: on: branch: master tags: true + +addons: + apt: + packages: + - pandoc diff --git a/setup.py b/setup.py index e0517b0..0134a74 100644 --- a/setup.py +++ b/setup.py @@ -204,6 +204,28 @@ def run(self): return behave.main([self.features_dir]) +def long_description(): + """Reads and returns the contents of the README. + + On failure, returns the project long description. + + Returns: + The project's long description. + """ + cwd = os.path.abspath(os.path.dirname(__file__)) + readme_path = os.path.join(cwd, 'README.md') + if not os.path.exists(readme_path): + return pylink.__long_description__ + + try: + import pypandoc + return pypandoc.convert(readme_path, 'rst') + except (IOError, ImportError): + pass + + return open(readme_path, 'r').read() + + setuptools.setup( # Project information. name='pylink-square', @@ -213,7 +235,7 @@ def run(self): author=pylink.__author__, author_email=pylink.__author_email__, description=pylink.__description__, - long_description=pylink.__long_description__, + long_description=long_description(), license=pylink.__license__, keywords='SEGGER J-Link', url=pylink.__url__,