Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack for distutils check --restructuredtext #1

Closed

Conversation

msabramo
Copy link

A Python distutils bug (http://bugs.python.org/issue23063) causes
python setup.py check --restructuredtext to fail on documents with
code blocks.

Fixes: SF-270 (https://sourceforge.net/p/docutils/bugs/270/)


python setup.py check --restructuredtext --strict --metadata fails with:

warning: check: Could not finish the parsing.

if the RST document uses code or code-block directives.

This is annoying because the document is valid, but it appears to be invalid and confuses people. For an example, see ionelmc/pytest-benchmark#4 (comment).

How to reproduce this bug

Clone a repo that has a README.rst with code-block directives in it. E.g.:

$ git clone [email protected]:ionelmc/pytest-benchmark.git
$ cd pytest-benchmark
$ git checkout ab0b08f6fccb06a7909905a8409f8faa8b01e0d8

Observe that it has "code-blocks" in it:

   $ grep 'code-block' README.rst
   .. code-block:: python
   .. code-block:: python

Observe that RST document is valid, according to rst2html.py:

   $ rst2html.py --halt=1 README.rst > README.html && echo "RST was OK."
   RST was OK.

   $ head -n 3 README.html
   <?xml version="1.0" encoding="utf-8" ?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Observe that python setup.py check --restructuredtext --strict --metadata fails:

$ python setup.py check --restructuredtext --strict --metadata
running check
warning: check: Could not finish the parsing.

error: Please correct your package.

$ echo $?
1

What was expected: python setup.py check --restructuredtext --strict --metadata should succeed with no warnings, just as rst2html.py did, because
README.rst is a valid RST document.

What actually happened: python setup.py check --restructuredtext --strict --metadata prints a warning and an error and fails, unlike rst2html.py

The error is coming from here:
https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py#L142

It's happening because of this line:
https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py#L125

settings = frontend.OptionParser().get_default_values()

If this is changed to:

settings = frontend.OptionParser(components=(Parser,)).get_default_values()

then things work much better (this is how tools/quicktest.py does it for example)

so this might actually be a bug in distutils, but changing CPython (and maybe PyPy) is a more laborious and slow process, so I'm thinking it might be nice to work around this in docutils, if isn't too much of a burden. Docutils is on a much shorter release cycle than CPython, so changing docutils is a way to get this fix out to users much faster.

A Python distutils bug (http://bugs.python.org/issue23063) causes
`python setup.py check --restructuredtext` to fail on documents with
code blocks.

Fixes: SF-270 (https://sourceforge.net/p/docutils/bugs/270/)
@msabramo
Copy link
Author

Oops. I did this by accident. I know your repo is a mirror of the svn repo.

@msabramo msabramo closed this Dec 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant