Example #1
0
def make_description_file(target_path):
    """
    Generate the long_description needed for setup.py.

    The long description needs to be formatted as reStructuredText:

      http://docs.python.org/distutils/setupscript.html#additional-meta-data

    """
    readme_path = README_PATH

    md_ext = os.path.splitext(readme_path)[1]

    # Remove our HTML comments because PyPI does not allow it.
    # See the setup.py docstring for more info on this.
    readme_text = strip_html_comments(readme_path)
    history_text = strip_html_comments(HISTORY_PATH)

    sections = [readme_text, history_text]
    md_description = '\n\n'.join(sections)

    md_description_path = make_temp_path(LONG_DESCRIPTION_PATH, new_ext=md_ext)

    log('writing: %s' % md_description_path)
    write(md_description, md_description_path)

    temp_path = make_temp_path(LONG_DESCRIPTION_PATH)
    rst_description = convert_md_to_rst(source_path=md_description_path,
                                        target_path=temp_path,
                                        docstring_path=__file__)

    # Comments in reST begin with two dots.
    intro_text = """\
.. This file is auto-generated by setup.py for PyPI using pandoc, so this
.. file should not be edited.  Edits should go in the source files.
"""

    rst_description = '\n'.join([intro_text, rst_description])

    write(rst_description, target_path)
Example #2
0
def publish(sys_argv):
    """
    Publish this package to PyPI (aka "the Cheeseshop").

    """
    description_path = LONG_DESCRIPTION_PATH
    temp_path = make_temp_path(description_path)
    make_description_file(temp_path)

    if read(temp_path) != read(description_path):
        print("""\
Description file not up-to-date: %s
Run the following command and commit the changes--

    python setup.py %s
""" % (description_path, COMMAND_PREP))
        sys.exit()

    print("Description up-to-date: %s" % description_path)

    # Upload to PyPI.
    sys_argv.extend([COMMAND_SDIST, COMMAND_UPLOAD])
    run_setup(sys_argv)
Example #3
0
 def test_new_ext(self):
     actual = make_temp_path('foo.rst', new_ext='.txt')
     self.assertEquals(actual, 'foo.temp.txt')
Example #4
0
 def test_rst(self):
     actual = make_temp_path('foo.rst')
     self.assertEquals(actual, 'foo.temp.rst')