|
1 | 1 | import os |
| 2 | +import contextlib |
| 3 | +import pathlib |
2 | 4 | from setuptools import setup, find_packages |
3 | 5 |
|
| 6 | +import pandoc |
| 7 | + |
4 | 8 | import metafunctions |
5 | 9 |
|
6 | 10 |
|
7 | 11 | here = os.path.abspath(os.path.dirname(__file__)) |
8 | 12 |
|
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 | + |
| 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