[Checkins] SVN: zc.async/trunk/ make setup hopefully more Windows friendly; and some automatic ReST validation of the long_description.

Gary Poster gary at zope.com
Thu Apr 24 06:35:21 EDT 2008


Log message for revision 85695:
  make setup hopefully more Windows friendly; and some automatic ReST validation of the long_description.

Changed:
  U   zc.async/trunk/buildout.cfg
  U   zc.async/trunk/setup.py
  U   zc.async/trunk/src/zc/async/README.txt

-=-
Modified: zc.async/trunk/buildout.cfg
===================================================================
--- zc.async/trunk/buildout.cfg	2008-04-24 10:33:31 UTC (rev 85694)
+++ zc.async/trunk/buildout.cfg	2008-04-24 10:35:21 UTC (rev 85695)
@@ -25,6 +25,7 @@
 [interpreter]
 recipe = zc.recipe.egg
 eggs = zc.async
+       docutils
 interpreter = py
 
 [z3interpreter]

Modified: zc.async/trunk/setup.py
===================================================================
--- zc.async/trunk/setup.py	2008-04-24 10:33:31 UTC (rev 85694)
+++ zc.async/trunk/setup.py	2008-04-24 10:35:21 UTC (rev 85695)
@@ -12,20 +12,63 @@
 #
 ##############################################################################
 import os
-
 from setuptools import setup, find_packages
 
-long_description = (
-    open('src/zc/async/README.txt').read() + "\n" +
-    open('src/zc/async/README_2.txt').read() + "\n" +
-    open('src/zc/async/README_3.txt').read() + "\n" +
-    open('src/zc/async/README_3b.txt').read() +
-    "\n\n=======\nChanges\n=======\n\n" +
-    open('src/zc/async/CHANGES.txt').read() + "\n")
+# generic helpers primarily for the long_description
+try:
+    import docutils
+except ImportError:
+    import warnings
+    def validateReST(text):
+        return ''
+else:
+    import docutils.utils
+    import docutils.parsers.rst
+    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.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()
 
-f = open('TEST_THIS_REST_BEFORE_REGISTERING.txt', 'w')
-f.write(long_description)
-f.close()
+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('.txt'):
+            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.txt'
+    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
 
 setup(
     name='zc.async',
@@ -36,7 +79,14 @@
     author='Gary Poster',
     author_email='gary at zope.com',
     description='Perform durable tasks asynchronously',
-    long_description=long_description,
+    long_description=text(
+        'src/zc/async/README.txt',
+        'src/zc/async/README_2.txt',
+        'src/zc/async/README_3.txt',
+        'src/zc/async/README_3b.txt',
+        "=======\nChanges\n=======\n\n",
+        'src/zc/async/CHANGES.txt',
+        out=True),
     license='ZPL',
     install_requires=[
         'ZODB3',

Modified: zc.async/trunk/src/zc/async/README.txt
===================================================================
--- zc.async/trunk/src/zc/async/README.txt	2008-04-24 10:33:31 UTC (rev 85694)
+++ zc.async/trunk/src/zc/async/README.txt	2008-04-24 10:35:21 UTC (rev 85695)
@@ -48,7 +48,7 @@
 
 This is a second-generation design.  The first generation was `zasync`,
 a mission-critical and successful Zope 2 product in use for a number of
-high-volume Zope 2 installations.  [#history]_ It's worthwhile noting
+high-volume Zope 2 installations.  [#async_history]_ It's worthwhile noting
 that zc.async has absolutely no backwards compatibility with zasync and
 zc.async does not require Zope (although it can be used in conjuction with it,
 details below).
@@ -835,7 +835,7 @@
 .. Footnotes ..
 .. ......... ..
 
-.. [#history] The first generation, zasync, had the following goals:
+.. [#async_history] The first generation, zasync, had the following goals:
 
     - be scalable, so that another process or machine could do the
       asynchronous work;



More information about the Checkins mailing list