Skip to content

Commit 8004120

Browse files
committed
Fall back on markdown if pandoc isn't available
This is less than ideal, but I think it'll suffice for now
1 parent 242775a commit 8004120

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

setup.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import os
22
import contextlib
33
import pathlib
4+
import shutil
45
from setuptools import setup, find_packages
56

6-
import pandoc
7+
has_pandoc = True
8+
try:
9+
import pandoc
10+
except ImportError:
11+
has_pandoc = False
712

813
import metafunctions
914

@@ -17,10 +22,13 @@ def md_to_rst(dir_):
1722
dir_ = pathlib.Path(dir_)
1823
rstfiles = []
1924
for mdfile in dir_.glob('*.md'):
20-
doc = pandoc.Document()
21-
doc.markdown = mdfile.read_bytes()
2225
rstfile = mdfile.with_suffix('.rst')
23-
rstfile.write_bytes(doc.rst)
26+
if has_pandoc:
27+
doc = pandoc.Document()
28+
doc.markdown = mdfile.read_bytes()
29+
rstfile.write_bytes(doc.rst)
30+
else:
31+
shutil.copy(mdfile, rstfile)
2432
rstfiles.append(rstfile)
2533

2634
yield rstfiles

0 commit comments

Comments
 (0)