Skip to content

Commit 242775a

Browse files
committed
Setup.py converts md to rst
1 parent 4e444a2 commit 242775a

File tree

2 files changed

+51
-24
lines changed

2 files changed

+51
-24
lines changed

metafunctions.wpr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ proj.directory-list = [{'dirloc': loc('metafunctions'),
1212
'watch_for_changes': True}]
1313
proj.file-list = [loc('setup.py')]
1414
proj.file-type = 'shared'
15+
proj.launch-config = {loc('setup.py'): ('project',
16+
(u'sdist\n',
17+
''))}
1518
testing.auto-test-file-specs = (('glob',
1619
'test_*.py'),)

setup.py

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,56 @@
11
import os
2+
import contextlib
3+
import pathlib
24
from setuptools import setup, find_packages
35

6+
import pandoc
7+
48
import metafunctions
59

610

711
here = os.path.abspath(os.path.dirname(__file__))
812

9-
# Get the long description from the README file
10-
with open(os.path.join(here, 'README.md')) as f:
11-
long_description = f.read()
12-
13-
setup(
14-
name=metafunctions.__name__,
15-
version=metafunctions.__version__,
16-
description='Metafunctions is a function composition and data pipelining library',
17-
long_description=long_description,
18-
url='https://github.com/ForeverWintr/metafunctions',
19-
author='Tom Rutherford',
20-
license='MIT',
21-
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
22-
classifiers=[
23-
'Development Status :: 3 - Alpha',
24-
'Intended Audience :: Developers',
25-
'Topic :: Software Development :: Libraries :: Python Modules',
26-
'License :: OSI Approved :: MIT License',
27-
'Programming Language :: Python :: 3.6',
28-
],
29-
keywords='functional-programming function-composition',
30-
packages=find_packages(),
31-
test_suite='metafunctions.tests',
32-
)
13+
@contextlib.contextmanager
14+
def md_to_rst(dir_):
15+
'''Convert anything with a .md extension to .rst for the duration of this context manager.
16+
'''
17+
dir_ = pathlib.Path(dir_)
18+
rstfiles = []
19+
for mdfile in dir_.glob('*.md'):
20+
doc = pandoc.Document()
21+
doc.markdown = mdfile.read_bytes()
22+
rstfile = mdfile.with_suffix('.rst')
23+
rstfile.write_bytes(doc.rst)
24+
rstfiles.append(rstfile)
25+
26+
yield rstfiles
27+
for f in rstfiles:
28+
f.unlink()
29+
30+
31+
with md_to_rst(here):
32+
with open(os.path.join(here, 'README.rst')) as f:
33+
long_description=f.read()
34+
35+
36+
setup(
37+
name=metafunctions.__name__,
38+
version=metafunctions.__version__,
39+
description='Metafunctions is a function composition and data pipelining library',
40+
long_description=long_description,
41+
url='https://github.com/ForeverWintr/metafunctions',
42+
author='Tom Rutherford',
43+
author_email='[email protected]',
44+
license='MIT',
45+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
46+
classifiers=[
47+
'Development Status :: 3 - Alpha',
48+
'Intended Audience :: Developers',
49+
'Topic :: Software Development :: Libraries :: Python Modules',
50+
'License :: OSI Approved :: MIT License',
51+
'Programming Language :: Python :: 3.6',
52+
],
53+
keywords='functional-programming function-composition',
54+
packages=find_packages(),
55+
test_suite='metafunctions.tests',
56+
)

0 commit comments

Comments
 (0)