def parse_md_readme(): """ pypi won't render markdown. After conversion to rst it will still not render unless raw directives are removed """ try: from m2r import parse_from_file rst_lines = parse_from_file('README.md').split('\n') long_description = [ '.. image:: http://mavis.bcgsc.ca/docs/latest/_static/acronym.svg\n\n|\n' ] # backup since pip can't handle raw directives i = 0 while i < len(rst_lines): if re.match(r'^..\s+raw::.*', rst_lines[i]): i += 1 while re.match(r'^(\s\s+|\t|$).*', rst_lines[i]): i += 1 else: long_description.append(re.sub( '>`_ ', '>`__ ', rst_lines[i])) # anonymous links i += 1 long_description = '\n'.join(long_description) except (ImportError, OSError): long_description = '' return long_description
def parse_md_to_rst(file): """Read Markdown file and convert to ReStructured Text.""" try: from m2r import parse_from_file return (parse_from_file(file)) except ImportError: # m2r may not be installed in user environment return (read(file))
def read_md(md_file): try: # pip install m2r from m2r import parse_from_file return parse_from_file(md_file) except ImportError: print("warning: m2r module not found, could not convert Markdown to RST") return open(md_file, 'r').read()
def readme(): """ Transform the given markdown README to RST. """ try: from m2r import parse_from_file return parse_from_file('README.md') except ImportError: with open('README.md') as stream: return stream.read()
def build_readme_rst_from_md(): readme_rst_path = os.path.join(docs_path, "README.rst") readme_md_path = os.path.join(os.path.dirname(docs_path), "README.md") readme = parse_from_file(readme_md_path) readme = readme.replace("~~", "--").replace("docs/img/", "img/") with open(readme_rst_path, "w+") as target_file: target_file.write(readme) return readme
def parse_md_to_rst(file): """Read Markdown file and convert to ReStructured Text.""" try: from m2r import parse_from_file return parse_from_file(file).replace("artwork/", "http://198.27.119.65/") except ImportError: # m2r may not be installed in user environment return read(file)
def parse_md_to_rst(file): """Read Markdown file and convert to ReStructured Text.""" try: from m2r import parse_from_file return parse_from_file(file).replace( "artwork/", "http://198.27.119.65/" ) except ImportError: # m2r may not be installed in user environment return read(file)
def read(fname): dname = os.path.dirname(__file__) fname = os.path.join(dname, fname) try: import m2r return m2r.parse_from_file(fname) except ImportError: with open(fname) as f: return f.read()
def parse_md_to_rst(files): """Read Markdown files and convert them to ReStructured Text.""" rst = [] try: from m2r import parse_from_file for name in files: rst += [parse_from_file(name)] except ImportError: # m2r may not be installed in user environment for name in files: rst += [read(name)] return '\n'.join(rst)
def export_md_in_rst(frad, export_subdir="docs"): root_path = get_root_path() fmd = Path(root_path, f"{frad}.md") frst = Path(root_path, export_subdir, f"{frad}.rst") rst_str = m2r.parse_from_file(fmd) if frst.exists(): frst.unlink() with open(frst, "w+") as rst_stream: rst_stream.write(rst_str) with open(frst, "r") as rst_stream: rst_str_new = rst_stream.read() return rst_str_new
def create_index_file(readme_location, package_rst): readme_ext = os.path.splitext(readme_location)[1] if readme_ext == ".md": output = parse_from_file(readme_location) elif readme_ext == ".rst": with open(readme_location, "r") as file: output = file.read() else: logging.error( "{} is not a valid readme type. Expecting RST or MD.".format( readme_location)) output += RST_EXTENSION_FOR_INDEX.format(package_rst) return output
# autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another # directory, add these directories to sys.path here. If the directory is # relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. # import os import sys from m2r import parse_from_file file = open('readme.rst', 'w', encoding='utf8') file.write(parse_from_file('../README.md')) file.close() file = open('history.rst', 'w', encoding='utf8') file.write(parse_from_file('../HISTORY.md')) file.close() sys.path.insert(0, os.path.abspath('..')) file = open('contributing.rst', 'w', encoding='utf8') file.write(parse_from_file('../CONTRIBUTING.md')) file.close() file = open('authors.rst', 'w', encoding='utf8') file.write(parse_from_file('../AUTHORS.md')) file.close()
import sys from setuptools import find_packages, setup from m2r import parse_from_file # Package meta-data. NAME = 'anago' DESCRIPTION = 'Sequence labeling library using Keras.' URL = 'https://github.com/Hironsan/anago' EMAIL = '*****@*****.**' AUTHOR = 'Hironsan' LICENSE = 'MIT' here = os.path.abspath(os.path.dirname(__file__)) long_description = parse_from_file(os.path.join(here, 'README.md')) about = {} with open(os.path.join(here, NAME, '__version__.py')) as f: exec(f.read(), about) if sys.argv[-1] == 'publish': os.system('python setup.py sdist bdist_wheel upload') sys.exit() required = [ 'Keras>=2.1.1', 'h5py>=2.7.1', 'scikit-learn>=0.19.1', 'numpy>=1.13.3', 'tensorflow>=1.4.0', ] setup( name=NAME,
#Napoleon settings napoleon_google_docstring = False napoleon_numpy_docstring = True napoleon_use_param = False napoleon_use_ivar = True napoleon_include_init_with_doc = True napoleon_include_private_with_doc = True napoleon_include_special_with_doc = False #NB-SPHINX nbsphinx_allow_errors = True #README - MD->rst: from m2r import parse_from_file output = parse_from_file('../../README.md') print(output) out_rst_file = open(os.getcwd() + "/introduction.rst", "w") out_rst_file.writelines(output) out_rst_file.close() # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document.
from setuptools import setup, find_packages from m2r import parse_from_file import json info = json.load(open('info.json')) with open('requirements.txt') as f: deps = [str(dep.strip()) for dep in f.readlines()] setup(name=info['name'], packages=find_packages('.'), version=info['version'], description='Performance hacking for your deep learning models', long_description=parse_from_file('README.md', encoding='utf-8'), author=info['authors'], url=info['github_url'], download_url='{}/tarball/v{}'.format(info['github_url'], info['version']), keywords=[ 'AI', 'ML', 'DL', 'deep learning', 'machine learning', 'neural network', 'deep neural network', 'debug neural networks', 'performance hacking', 'tensorflow', 'tf' ], license='Apache License 2.0', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3',
new_file_path = os.path.join(os.path.dirname(filepath or "."), new_filename) requirements.extend(parse_reqs(new_file_path)) elif line.startswith("-f") or line.startswith("-i") or line.startswith( "--"): continue elif line.startswith("-Z") or line.startswith("--always-unzip"): continue else: requirements.append(line) return requirements version = "0.1.0" readme = open("README.rst").read() history = parse_from_file("CHANGELOG.md") requirements = parse_reqs("requirements.txt") test_requirements = parse_reqs("requirements/test.txt") setup( author="Data Science Team", author_email="*****@*****.**", classifiers=[ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Natural Language :: English", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", ], description="", install_requires=requirements,
requirements.extend(parse_reqs(new_file_path)) elif line.startswith('-f') or line.startswith('--find-links') or \ line.startswith('-i') or line.startswith('--index-url') or \ line.startswith('--extra-index-url') or \ line.startswith('--no-index'): continue elif line.startswith('-Z') or line.startswith('--always-unzip'): continue else: requirements.append(line) return requirements version = get_version("testpkg", "__init__.py") readme = open('README.rst').read() history = parse_from_file('CHANGELOG.md') setup( name='django-testpkg', version=version, description="""Your project description goes here""", long_description=readme + '\n\n' + history, author='Corey Oordt', author_email='*****@*****.**', url='https://github.com/coordt/django-testpkg', packages=find_packages(exclude=[ 'example*', 'tests*', 'docs', 'build', ]),
#!/usr/bin/python from setuptools import setup from mister_bump import bump from m2r import parse_from_file import restructuredtext_lint # Parser README.md into reStructuredText format rst_readme = parse_from_file('README.md') # Validate the README, checking for errors errors = restructuredtext_lint.lint(rst_readme) # Raise an exception for any errors found if errors: print(rst_readme) raise ValueError('README.md contains errors: ', ', '.join([e.message for e in errors])) setup(name='anybadge', description='Simple, flexible badge generator for project badges.', long_description=rst_readme, version=bump(), author='Jon Grace-Cox', author_email='*****@*****.**', py_modules=['anybadge', 'anybadge_server'], setup_requires=['setuptools', 'wheel'], tests_require=[], install_requires=[], data_files=[], options={'bdist_wheel': { 'universal': True
from os import path from setuptools import find_packages, setup README_PATH = path.join(path.dirname(path.abspath(__file__)), 'README.md') try: import m2r LONG_DESCRIPTION = m2r.parse_from_file(README_PATH) except (ImportError, IOError, FileNotFoundError): # m2r not installed or file does not exist LONG_DESCRIPTION = '' setup( name='django-feature-flipper', author='Pebble', author_email='*****@*****.**', description='A simple, customisable, feature flipper', url='https://github.com/mypebble/django-feature-flipper.git', version='0.1.3', packages=find_packages(), license='MIT', long_description=LONG_DESCRIPTION, install_requires=[ 'django', ] )
from distutils.core import setup import inspect import os, errno SETUP_PY_FILENAME = inspect.getframeinfo(inspect.currentframe()).filename ROOT_DIR = os.path.dirname(os.path.abspath(SETUP_PY_FILENAME)) README_MD_PATH = os.path.join(ROOT_DIR, 'README.md') README_RST_PATH = os.path.join(ROOT_DIR, 'README.rst') README_TXT_PATH = os.path.join(ROOT_DIR, 'README.txt') VERSION_TXT_PATH = os.path.join(ROOT_DIR, 'VERSION') try: from m2r import parse_from_file readme = parse_from_file(README_MD_PATH) f = open(README_RST_PATH,'w') f.write(readme) f.close() os_symlink = getattr(os, "symlink", None) if callable(os_symlink): try: os.symlink(README_RST_PATH, README_TXT_PATH) except OSError, e: if e.errno == errno.EEXIST: os.remove(README_TXT_PATH) os.symlink(README_RST_PATH, README_TXT_PATH) else: f = open(README_TXT_PATH,'w') f.write(readme) f.close() except ImportError: # m2r may not be installed in user environment
from __future__ import print_function import sys from setuptools import setup try: import m2r long_description = m2r.parse_from_file('README.md') except(IOError, ImportError): print('Markdown not converted to rst') long_description = open('README.md').read() about = {} with open("./oommftools/_about.py") as fp: exec(fp.read(), about) setup( name=about['__title__'].lower(), version=about['__version__'], description=''.join(about['__summary__']), long_description=long_description, author=about['__author__'], maintainer=about['__maintainer__'], license='GPLv2', author_email=about['__email__'], url=about['__uri__'], packages=['oommftools'], # same as name setup_requires=['pytest-runner'], install_requires=['scipy', 'numpy', 'future', 'pytest'] + ( ["wxpython"] if not sys.platform.startswith("linux") else [] ), # external packages as dependencies tests_require=['pytest'],
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from os import path try: from setuptools import setup except ImportError: from distutils.core import setup readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md') try: from m2r import parse_from_file readme = parse_from_file(readme_file) except ImportError: with open(readme_file) as f: readme = f.read() install_requires = ['mistune', 'docutils'] test_requirements = ['pygments'] if sys.version_info < (3, 3): test_requirements.append('mock') setup( name='m2r', version='0.2.1', description='Markdown and reStructuredText in a single file.', long_description=readme, author='Hiroyuki Takagi', author_email='*****@*****.**',
""" Setup file for automat """ from setuptools import setup, find_packages try: from m2r import parse_from_file long_description = parse_from_file('README.md') except (IOError, ImportError): print( "\n\n!!! m2r not found, long_description is bad, don't upload this to PyPI !!!\n\n" ) import io long_description = io.open('README.md', encoding="utf-8").read() setup( name='Automat', use_scm_version=True, url='https://github.com/glyph/Automat', description=""" Self-service finite-state machines for the programmer on the go. """.strip(), long_description=long_description, packages=find_packages(exclude=[]), package_dir={'automat': 'automat'}, setup_requires=[ 'setuptools-scm', 'm2r', ], install_requires=[
from distutils.core import setup import inspect import os, errno SETUP_PY_FILENAME = inspect.getframeinfo(inspect.currentframe()).filename ROOT_DIR = os.path.dirname(os.path.abspath(SETUP_PY_FILENAME)) README_MD_PATH = os.path.join(ROOT_DIR, 'README.md') README_RST_PATH = os.path.join(ROOT_DIR, 'README.rst') README_TXT_PATH = os.path.join(ROOT_DIR, 'README.txt') VERSION_TXT_PATH = os.path.join(ROOT_DIR, 'VERSION') try: from m2r import parse_from_file readme = parse_from_file(README_MD_PATH) f = open(README_RST_PATH, 'w') f.write(readme) f.close() os_symlink = getattr(os, "symlink", None) if callable(os_symlink): try: os.symlink(README_RST_PATH, README_TXT_PATH) except OSError, e: if e.errno == errno.EEXIST: os.remove(README_TXT_PATH) os.symlink(README_RST_PATH, README_TXT_PATH) else: f = open(README_TXT_PATH, 'w') f.write(readme) f.close() except ImportError: # m2r may not be installed in user environment
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import codecs from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) readme_file = os.path.join(here, 'README.md') try: from m2r import parse_from_file long_description = parse_from_file(readme_file) except ImportError: with codecs.open(readme_file, encoding='utf-8') as f: long_description = f.read() terminal_notifier_files = [] for root, dirs, files in os.walk('pync/vendor/'): root = '/'.join(root.split('/')[1:]) for f in files: terminal_notifier_files.append(os.path.join(root, f)) setup(name = 'pync', version = "2.0.3", description = 'Python Wrapper for Mac OS 10.10 Notification Center', long_description = long_description, author = 'Vladislav Syabruk', author_email = '*****@*****.**', url = 'https://github.com/setem/pync',
#!/usr/bin/env python import os from setuptools import find_packages, setup readme_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md') try: from m2r import parse_from_file README = parse_from_file(readme_file) except ImportError: # m2r may not be installed in user environment with open(readme_file) as f: README = f.read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) def _read(relpath): fullpath = os.path.join(os.path.dirname(__file__), relpath) with open(fullpath) as f: return f.read() def _read_reqs(relpath): fullpath = os.path.join(os.path.dirname(__file__), relpath) with open(fullpath) as f: return [ s.strip() for s in f.readlines() if (s.strip() and not s.startswith("#"))
# (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'MPAS-Analysis', u'MPAS-Analysis Documentation', author, 'MPAS-Analysis', 'One line description of project.', 'Miscellaneous'), ] # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'python': ('https://docs.python.org/', None), 'numpy': ('http://docs.scipy.org/doc/numpy/', None), 'xarray': ('http://xarray.pydata.org/en/stable/', None) } # Build some custom rst files xmlFileName = '../mpas_analysis/obs/observational_datasets.xml' for component in ['ocean', 'seaice']: build_rst_table_from_xml(xmlFileName, '{}_obs_table.rst'.format(component), component) build_obs_pages_from_xml(xmlFileName) build_quick_start() for mdFileName in glob('design_docs/*.md'): output = m2r.parse_from_file(mdFileName) rstFileName = os.path.splitext(mdFileName)[0] + '.rst' outFile = open(rstFileName, 'w') outFile.write(output) github_doc_root = 'https://github.com/rtfd/recommonmark/tree/master/doc/'
elif value.upper() == 'TRUE': return True else: return False # numpy distutils does not support passing long_description_content_type # so we'll have to manually convert to rst and strip out the html in the header # but we also don't want to have to make m2r a hard dependency for installation try: import m2r except ImportError: with open('README.md', 'r') as fh: long_description = fh.read() else: long_description_s = m2r.parse_from_file("README.md").split('\n') long_description = "\n".join( long_description_s[long_description_s.index("INTRODUCTION"):]) setup(name='phoebe', version='2.3.3', description='PHOEBE 2.3.3', long_description=long_description, author='PHOEBE development team', author_email='*****@*****.**', url='http://github.com/phoebe-project/phoebe2', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', 'Topic :: Software Development :: Build Tools', "Natural Language :: English",
#!/usr/bin/env python # -*- coding: utf-8 -*- from os import path from dpgen import NAME, SHORT_CMD import setuptools readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md') try: from m2r import parse_from_file readme = parse_from_file(readme_file) except ImportError: with open(readme_file) as f: readme = f.read() install_requires = [ 'numpy>=1.14.3', 'dpdata>=0.1.5', 'pymatgen>=2017.9.1', 'ase', 'monty>2.0.0', 'paramiko', 'custodian' ] setuptools.setup( name=NAME, version_format='{tag}.dev{commitcount}+{gitsha}', setup_requires=['setuptools-git-version'], author="Han Wang", author_email="*****@*****.**", description="DPGen: The deep potential generator", long_description=readme, long_description_content_type="text/markdown", url="https://github.com/deepmodeling/dpgen", packages=[
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import codecs from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) readme_file = os.path.join(here, 'README.md') try: from m2r import parse_from_file long_description = parse_from_file(readme_file) except ImportError: with codecs.open(readme_file, encoding='utf-8') as f: long_description = f.read() terminal_notifier_files = [] for root, dirs, files in os.walk('pync/vendor/'): root = '/'.join(root.split('/')[1:]) for f in files: terminal_notifier_files.append(os.path.join(root, f)) setup(name = 'pync', version = "2.0.4", description = 'Python Wrapper for Mac OS 10.10 Notification Center', long_description = long_description, author = 'Vladislav Syabruk', author_email = '*****@*****.**', url = 'https://github.com/setem/pync',
# -------------------------------------------- # Copyright 2020, Grant Viklund # @Author: Grant Viklund # @Date: 2020-01-08 12:34:05 # -------------------------------------------- from os import path from setuptools import setup, find_packages from permafrost.__version__ import VERSION readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md') try: from m2r import parse_from_file long_description = parse_from_file(readme_file) # Convert the file to RST for PyPI except ImportError: # m2r may not be installed in user environment with open(readme_file) as f: long_description = f.read() package_metadata = { 'name': 'django-permafrost', 'description': 'Adds Client Definable Permissions to Django', 'version': VERSION, 'long_description': long_description, 'url': 'https://github.com/renderbox/django-permafrost/', 'author': 'Grant Viklund', 'author_email': '*****@*****.**', 'license': 'MIT license', 'classifiers': [
NAME = 'PySlowLoris' DESCRIPTION = 'Small and simple tool for testing Slow Loris vulnerability' URL = 'https://github.com/maxkrivich/slowloris/' EMAIL = '*****@*****.**' AUTHOR = 'Maxim Krivich' ABOUT = {} with open(os.path.join(here, NAME, '__version__.py')) as f: exec(f.read(), ABOUT) readme_file = os.path.join(here, 'README.md') try: from m2r import parse_from_file LONG_DESCRIPTION = parse_from_file(readme_file) except ImportError: with codecs.open(readme_file, encoding='utf-8') as f: LONG_DESCRIPTION = f.read() with codecs.open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as f: REQUIREMENTS = f.read().splitlines() class PublishCommand(Command): """Support setup.py publish.""" description = 'Build and publish the package.' user_options = []
"opencv-python~=4.2", "numpy~=1.18", ] __entry_points__ = { "console_scripts": [ "cameraman = simplecameraman.cameraman:main", ], } __long_description__ = "" try: # Reformat description as PyPi use ReStructuredText rather than Markdown import m2r __long_description__ = m2r.parse_from_file( os.path.join(base_dir, "README.md")) except (ImportError, IOError, OSError) as e: import logging logging.warning(f"m2r conversion failed: {e}") CLASSIFIERS = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3 :: Only", ] setup(
from distutils.core import setup from pathlib import Path short_description = "A simple python wrapper script for bootstrapping a reverse proxy inside a docker container." try: if (Path().parent / "README.rst").is_file(): with open(str(Path().parent / "README.rst")) as readme_file: long_description = readme_file.read() elif (Path().parent / "README.md").is_file(): import m2r long_description = m2r.parse_from_file(Path().parent / "README.md") else: raise AssertionError("No readme file") except (ImportError, AssertionError): long_description = short_description setup( name="proxybootstrap", packages=["proxybootstrap"], version="0.1.8", license="MIT", description=short_description, long_description=long_description, author="romnn", author_email="*****@*****.**", url="https://github.com/romnn/proxybootstrap", keywords=[ "reverse", "proxy", "container", "docker", "wrapper", "CORS", "nginx" ],
def test_parse_file(self): output = parse_from_file(test_md) with open(test_rst) as f: expected = f.read() self.assertEqual(output.strip(), expected.strip())
#!/usr/bin/env python3 from setuptools import setup try: # noinspection PyUnresolvedReferences from m2r import parse_from_file except ImportError: ld = ':code:`Could not load m2r module.`' else: ld = parse_from_file('README.md') from misskey import __version__ as mkp_version setup( name='Misskey.py', version=mkp_version, description='The misskey library for Python. misskey is made by syuilo.', long_description=ld, keywords=[ 'misskey', 'API', 'library', 'syuilo', 'SNS', 'Social Networking Service', ], author='YuzuRyo61', url='https://github.com/YuzuRyo61/Misskey.py', license='MIT', install_requires=[
def convert_readme(): from m2r import parse_from_file rst = parse_from_file('README.md') with open('README.rst', 'w') as f: f.write(rst) return rst