Skip to content

Regression: Docs no longer build with py27-sphinx since #2394 #2593

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

Closed
zmwangx opened this issue Dec 20, 2016 · 6 comments
Closed

Regression: Docs no longer build with py27-sphinx since #2394 #2593

zmwangx opened this issue Dec 20, 2016 · 6 comments

Comments

@zmwangx
Copy link

zmwangx commented Dec 20, 2016

Docs used to build just fine with Sphinx under Python 2.7. #2394 introduced an import mypy.git to mypy.version (which is imported by Sphinx's conf.py), and since mypy.git contains function annotations not supported by Python 2.7, trying to build the docs with py27-sphinx now causes an error:

$ make html
sphinx-build -b html -d build/doctrees   source build/html
Running Sphinx v1.5.1

Configuration error:
There is a syntax error in your configuration file: invalid syntax (git.py, line 10)
make: *** [html] Error 1

This unfortunately is causing some trouble for Homebrew (see Homebrew/homebrew-core#7143), since our sphinx-doc formula is py27 only at the moment.

We'll of course try to fix this on Homebrew's side, but maybe py27-sphinx compatibility could be restored? One solution I can think of is to add something like mypy/version_static.py with the plain old version declaration:

__version__ = '0.4.7-dev'

then import mypy.version_static in docs/source/conf.py instead. The downside is it needs to be bumped alongside version.py at the same time, and when building from a git tree, the commit hash won't be included in the docs.

@ambv
Copy link
Contributor

ambv commented Dec 20, 2016

I personally like what Pallets' projects are doing: AST analyzing the version string, without really importing it, like: https://github.com/pallets/click/blob/master/setup.py#L11.

We'd need typed-ast instead to be able to generate the AST on Python 2 as well and we should be all set. Let me see how much work it is to prepare a PR for this.

@ambv
Copy link
Contributor

ambv commented Dec 20, 2016

Turns out we don't even need typed-ast if we only evaluate the string found in the version assignment.

zmwangx added a commit to zmwangx/homebrew-core that referenced this issue Dec 20, 2016
- Add mypy/version_static.py during doc build to work around
  python/mypy#2593. Pending official patch or
  rejection of py27-sphinx compatibility.

- Fix Sphinx theme. Sphinx does NOT recognize PYTHONPATH, so installing
  sphinx_rtd_theme to libexec/vendor then pointing PYTHONPATH there is
  useless. Instead, we install sphinx_rtd_theme to buildpath/docs, then
  directly modify sys.path in Sphinx's conf.py.
@gvanrossum
Copy link
Member

gvanrossum commented Dec 21, 2016 via email

nijikon pushed a commit to Homebrew/homebrew-core that referenced this issue Dec 21, 2016
- Add mypy/version_static.py during doc build to work around
  python/mypy#2593. Pending official patch or
  rejection of py27-sphinx compatibility.

- Fix Sphinx theme. Sphinx does NOT recognize PYTHONPATH, so installing
  sphinx_rtd_theme to libexec/vendor then pointing PYTHONPATH there is
  useless. Instead, we install sphinx_rtd_theme to buildpath/docs, then
  directly modify sys.path in Sphinx's conf.py.

Closes #8073.

Signed-off-by: Tomasz Pajor <[email protected]>
@gvanrossum
Copy link
Member

@ambv Since you closed your PR, did you intend this issue to be closed with "won't fix" as well?

@zmwangx
Copy link
Author

zmwangx commented Dec 23, 2016

As the OP I'm okay with wont fix. I've patched the Homebrew formula (with the version_static hack mentioned above, only at build time) and no one's mad at me so far.

@ambv
Copy link
Contributor

ambv commented Dec 23, 2016

@ambv GitHub closed it since I mistakenly put it on master in my fork :)

But yeah, if wontfix is okay for @zmwangx, it's better for us to keep things simple.

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

No branches or pull requests

3 participants