chiark / gitweb /
use pandoc to convert README.md to PyPI's reST format
authorHans-Christoph Steiner <hans@eds.org>
Wed, 20 Sep 2017 09:48:49 +0000 (11:48 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 25 Sep 2017 14:35:18 +0000 (16:35 +0200)
PyPI and Python packages expect the description to be in reST format, which
is a lot different than Markdown.  This does the conversion if pandoc is
installed.

setup.cfg
setup.py

index 069fb320b93ca3b70ca67e5b47c56101207904b9..1cca664328fb3dd7038346da7fabf07ef61708cd 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,3 @@
-[metadata]
-description-file = README.md
 
 [aliases]
 release = register sdist upload --sign
-
index ef153039374dfb903ddc0eb3708e78ccbd4b8b39..15544732e01a20f1f29cc71093a4ca5cf09be4b4 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,6 +2,7 @@
 
 from setuptools import setup
 import os
+import shutil
 import sys
 
 # workaround issue on OSX or --user installs, where sys.prefix is not an installable location
@@ -10,10 +11,21 @@ if os.access(sys.prefix, os.W_OK | os.X_OK):
 else:
     data_prefix = '.'
 
+# PyPI accepts reST not Markdown
+if shutil.which('pandoc'):
+    print('Using reST README')
+    import subprocess
+    readme = subprocess.check_output(['pandoc', '--from=markdown', '--to=rst', 'README.md'],
+                                     universal_newlines=True)
+else:
+    print('Using Markdown README')
+    with open('README.md') as fp:
+        readme = fp.read()
+
 setup(name='fdroidserver',
       version='0.8',
       description='F-Droid Server Tools',
-      long_description=open('README.md').read(),
+      long_description=readme,
       author='The F-Droid Project',
       author_email='team@f-droid.org',
       url='https://f-droid.org',