Skip to content

Commit

Permalink
Fix PyPI page by using correct ReST syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Jun 18, 2018
1 parent 828559c commit 94dae0a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 76 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.tox/
/local/
/src-dev/
TEST_THIS_REST_BEFORE_REGISTERING.txt
__pycache__/
bin/
build/
Expand Down
14 changes: 4 additions & 10 deletions DEVELOP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ To run tests, run *both* of the following:

Changes should be documented in CHANGES.rst *in the package*.

Before making a release that registers the software to PyPI, run the following:
Before making a release that registers the software to PyPI, run the
`longtest` command of the ``zest.releaser`` package to check for errors
in the ``long_description``.

- ``./bin/py setup.py``

This then creates a file with the following silly name:
``TEST_THIS_REST_BEFORE_REGISTERING.rst``

As the name suggests, test the file in a ReST tool to make sure docutils
parses it correctly.

Once this works, go ahead and ``./bin/py setup.py sdist register upload``.
Once this works, go ahead and ``./bin/py setup.py sdist upload``.
76 changes: 12 additions & 64 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,11 @@
from setuptools import find_packages
from setuptools import setup

# generic helpers primarily for the long_description
try:
import docutils
except ImportError:
def validateReST(text):
return ''
else:
import docutils.utils
import docutils.parsers.rst
try:
from StringIO import StringIO
except ImportError:
from io import StringIO

def validateReST(text):
doc = docutils.utils.new_document('validator')
# our desired settings
doc.reporter.halt_level = 5
doc.reporter.report_level = 1
stream = doc.reporter.stream = StringIO()
# docutils buglets (?)
doc.settings.tab_width = 2
doc.settings.pep_references = doc.settings.rfc_references = False
doc.settings.trim_footnote_reference_space = None
# and we're off...
parser = docutils.parsers.rst.Parser()
parser.parse(text, doc)
return stream.getvalue()


def text(*args, **kwargs):
# note: distutils explicitly disallows unicode for setup values :-/
# http://docs.python.org/dist/meta-data.html
tmp = []
for a in args:
if a.endswith('.rst'):
f = open(os.path.join(*a.split('/')))
tmp.append(f.read())
f.close()
tmp.append('\n\n')
else:
tmp.append(a)
if len(tmp) == 1:
res = tmp[0]
else:
res = ''.join(tmp)
out = kwargs.get('out')
if out is True:
out = 'TEST_THIS_REST_BEFORE_REGISTERING.rst'
if out:
f = open(out, 'w')
f.write(res)
f.close()
report = validateReST(res)
if report:
print(report)
raise ValueError('ReST validation error')
return res
# end helpers; below this line should be code custom to this package
def read(path):
"""Read the contents of a file system path."""
with open(os.path.join(*path.split('/'))) as f:
return f.read()


setup(
Expand All @@ -90,12 +36,14 @@ def text(*args, **kwargs):
author='Gary Poster',
author_email='gary@zope.com',
url="https://github.com/zopefoundation/zc.relation",
description=text("README.rst"),
long_description=text('src/zc/relation/README.rst',
'src/zc/relation/tokens.rst',
'src/zc/relation/searchindex.rst',
'src/zc/relation/optimization.rst',
'src/zc/relation/CHANGES.rst'),
description=read("README.rst"),
long_description="\n\n".join([
read('src/zc/relation/README.rst'),
read('src/zc/relation/tokens.rst'),
read('src/zc/relation/searchindex.rst'),
read('src/zc/relation/optimization.rst'),
read('src/zc/relation/CHANGES.rst'),
]),
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
Expand Down
2 changes: 1 addition & 1 deletion src/zc/relation/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changes
1.2 (unreleased)
================

- Nothing changed yet.
- Fix PyPI page by using correct ReST syntax.


1.1 (2018-06-15)
Expand Down

0 comments on commit 94dae0a

Please sign in to comment.