-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24530][PYTHON] Add a control to force Python version in Sphinx via environment variable, SPHINXPYTHON #21659
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
Conversation
|
cc @mengxr, let me update the release process and doc on this weekend separately. I was just looking into this script out of curiosity and I felt it's worth adding it to explicitly force the Python version used by Sphinx. |
|
Test build #92430 has finished for PR 21659 at commit
|
python/docs/Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
less then -> less than.
|
Test build #92431 has finished for PR 21659 at commit
|
|
Test build #92444 has finished for PR 21659 at commit
|
|
Test build #92450 has finished for PR 21659 at commit
|
python/docs/Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put in SPHINXOPTS?
|
Haa ... I guess API documentation builder in Jenkins should probably be broken if this one is merged in as is .. and the env there should be updated too.. Let me try to tweak this a bit on this weekend together. |
|
Test build #92451 has finished for PR 21659 at commit
|
|
Test build #92452 has finished for PR 21659 at commit
|
|
Test build #92453 has finished for PR 21659 at commit
|
|
retest this please. |
|
Now, it keeps the previous behaviour and use the Python iff |
python/docs/Makefile
Outdated
| # | ||
|
|
||
| ifndef SPHINXPYTHON | ||
| SPHINXBUILD ?= sphinx-build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both are set, we prefer SPHINXPYTHON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, I updated the manual tests above. There are commands executed in the logs.
| # User-friendly check for sphinx-build if explicitly specified. | ||
| ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) | ||
| $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) | ||
| endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If SPHINXPYTHON -msphinx' is preferred instead of 'sphinx-build' by default, should we go for a default SPHINXPYTHON + -msphinx instead of a default SPHINXBUILD if both are not set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea... that was the problem I faced.. Probably we should change but seems it needs some changes in Jenkins environment .. FYI there are some discussion about the potential effect by setting that as a default in the PR link of the comments.
I was thinking we set SPHINXPYTHON manually when we make a release for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems error prone - why not pick a good default of python3 and allow overriding?
|
Test build #92468 has finished for PR 21659 at commit
|
|
Test build #92469 has finished for PR 21659 at commit
|
|
Test build #92462 has finished for PR 21659 at commit
|
holdenk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this issue! It seems like we could improve this by setting the default to Python3 and allowing override to Python2?
python/docs/Makefile
Outdated
| SPHINXBUILD ?= sphinx-build | ||
| PAPER ?= | ||
| BUILDDIR ?= _build | ||
| # Also, you can set SPHINXBUILD to specify Sphinx build executable or SPHINXPYTHON to specify the Python executable used in Sphinx. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify the priority here.
| # User-friendly check for sphinx-build if explicitly specified. | ||
| ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) | ||
| $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) | ||
| endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems error prone - why not pick a good default of python3 and allow overriding?
|
re: #21659 (comment) Thing is, the build fails on Jenkins and it will probably fail on documentation builder in Jenkins. For now, I just gave a higher priority to Now, |
|
Test build #92531 has finished for PR 21659 at commit
|
|
Test build #92532 has finished for PR 21659 at commit
|
|
@HyukjinKwon I reported the issue to Sphinx at sphinx-doc/sphinx#5142. We are not sure if Python 2 is the root cause. I don't have strong preferences on the approaches discussed here. But maybe we should wait and see if there is a fix/workaround from upstream. |
|
@mengxr, thanks for reporting it. This will probably related with FWIW, I believe the API documentation fixes in spark-website can be orthogonally progressed. |
|
When you say orthogonally do you mean with another PR? |
| endif | ||
| endif | ||
|
|
||
| ifdef SPHINXBUILD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to check that Sphinx build is running with Py3 as done bellow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find an easy way.
|
Ah, I mean PRs in spark-website to fix the API documentation. |
|
retest this please |
|
Test build #92724 has finished for PR 21659 at commit
|
This reverts commit 950ead0.
| else | ||
| # Note that there is an issue with Python version and Sphinx in PySpark documentation generation. | ||
| # Please remove this check below when this issue is fixed. See SPARK-24530 for more details. | ||
| PYTHON_VERSION_CHECK = $(shell $(SPHINXPYTHON) -c 'import sys; print(sys.version_info < (3, 0, 0))') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix the SPHINXPYTHON to python3 in release script release-build.sh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or add some options/outputs in release script to let others know how to workaround this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forcing SPHINXPYTHON to python3 by default will probably break the distribution builder in Jenkins if they are tried ... Seems there's an issue to force Sphinx to use Python 3 in Jenkins environment. This was the problem I struggled to tweak :(.
Am trying to update the release process - apache/spark-website#122. Would this be enough to address your concern?
|
Test build #92725 has finished for PR 21659 at commit
|
|
Test build #92726 has finished for PR 21659 at commit
|
docs/README.md
Outdated
| `$SPARK_HOME/python/docs` directory. Documentation is only generated for classes that are listed as | ||
| public in `__init__.py`. The SparkR docs can be built by running `$SPARK_HOME/R/create-docs.sh`, and | ||
| public in `__init__.py`. You can also set `SPHINXPYTHON` to specify the Python executable to use with Sphinx. | ||
| The SparkR docs can be built by running `$SPARK_HOME/R/create-docs.sh`, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me take out this change in this PR, actually. It makes backporting harder
|
@mengxr, mind if I go ahead? This seems actually bothering release processes. |
|
Test build #92784 has finished for PR 21659 at commit
|
|
I think we can treat this fix as a temp fix, once sphinx issue is resolved, we can update in Spark accordingly. This is not a big problem, only affects python doc, so I think it is safe to merge. |
|
Let me push this one. Also, it doesn't change anything by default. |
|
Merged to master and branch-2.3. |
… via environment variable, SPHINXPYTHON ## What changes were proposed in this pull request? This PR proposes to add `SPHINXPYTHON` environment variable to control the Python version used by Sphinx. The motivation of this environment variable is, it seems not properly rendering some signatures in the Python documentation when Python 2 is used by Sphinx. See the JIRA's case. It should be encouraged to use Python 3, but looks we will probably live with this problem for a long while in any event. For the default case of `make html`, it keeps previous behaviour and use `SPHINXBUILD` as it was. If `SPHINXPYTHON` is set, then it forces Sphinx to use the specific Python version. ``` $ SPHINXPYTHON=python3 make html python3 -msphinx -b html -d _build/doctrees . _build/html Running Sphinx v1.7.5 ... ``` 1. if `SPHINXPYTHON` is set, use Python. If `SPHINXBUILD` is set, use sphinx-build. 2. If both are set, `SPHINXBUILD` has a higher priority over `SPHINXPYTHON` 3. By default, `SPHINXBUILD` is used as 'sphinx-build'. Probably, we can somehow work around this via explicitly setting `SPHINXBUILD` but `sphinx-build` can't be easily distinguished since it (at least in my environment and up to my knowledge) doesn't replace `sphinx-build` when newer Sphinx is installed in different Python version. It confuses and doesn't warn for its Python version. ## How was this patch tested? Manually tested: **`python` (Python 2.7) in the path with Sphinx:** ``` $ make html sphinx-build -b html -d _build/doctrees . _build/html Running Sphinx v1.7.5 ... ``` **`python` (Python 2.7) in the path without Sphinx:** ``` $ make html Makefile:8: *** The 'sphinx-build' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the 'sphinx-build' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/. Stop. ``` **`SPHINXPYTHON` set `python` (Python 2.7) with Sphinx:** ``` $ SPHINXPYTHON=python make html Makefile:35: *** Note that Python 3 is required to generate PySpark documentation correctly for now. Current Python executable was less than Python 3. See SPARK-24530. To force Sphinx to use a specific Python executable, please set SPHINXPYTHON to point to the Python 3 executable.. Stop. ``` **`SPHINXPYTHON` set `python` (Python 2.7) without Sphinx:** ``` $ SPHINXPYTHON=python make html Makefile:35: *** Note that Python 3 is required to generate PySpark documentation correctly for now. Current Python executable was less than Python 3. See SPARK-24530. To force Sphinx to use a specific Python executable, please set SPHINXPYTHON to point to the Python 3 executable.. Stop. ``` **`SPHINXPYTHON` set `python3` with Sphinx:** ``` $ SPHINXPYTHON=python3 make html python3 -msphinx -b html -d _build/doctrees . _build/html Running Sphinx v1.7.5 ... ``` **`SPHINXPYTHON` set `python3` without Sphinx:** ``` $ SPHINXPYTHON=python3 make html Makefile:39: *** Python executable 'python3' did not have Sphinx installed. Make sure you have Sphinx installed, then set the SPHINXPYTHON environment variable to point to the Python executable having Sphinx installed. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/. Stop. ``` **`SPHINXBUILD` set:** ``` $ SPHINXBUILD=sphinx-build make html sphinx-build -b html -d _build/doctrees . _build/html Running Sphinx v1.7.5 ... ``` **Both `SPHINXPYTHON` and `SPHINXBUILD` are set:** ``` $ SPHINXBUILD=sphinx-build SPHINXPYTHON=python make html sphinx-build -b html -d _build/doctrees . _build/html Running Sphinx v1.7.5 ... ``` Author: hyukjinkwon <[email protected]> Closes #21659 from HyukjinKwon/SPARK-24530. (cherry picked from commit 1f94bf4) Signed-off-by: hyukjinkwon <[email protected]>
|
cc @cloud-fan fyi |
What changes were proposed in this pull request?
This PR proposes to add
SPHINXPYTHONenvironment variable to control the Python version used by Sphinx.The motivation of this environment variable is, it seems not properly rendering some signatures in the Python documentation when Python 2 is used by Sphinx. See the JIRA's case. It should be encouraged to use Python 3, but looks we will probably live with this problem for a long while in any event.
For the default case of
make html, it keeps previous behaviour and useSPHINXBUILDas it was. IfSPHINXPYTHONis set, then it forces Sphinx to use the specific Python version.SPHINXPYTHONis set, use Python. IfSPHINXBUILDis set, use sphinx-build.SPHINXBUILDhas a higher priority overSPHINXPYTHONSPHINXBUILDis used as 'sphinx-build'.Probably, we can somehow work around this via explicitly setting
SPHINXBUILDbutsphinx-buildcan't be easily distinguished since it (at least in my environment and up to my knowledge) doesn't replacesphinx-buildwhen newer Sphinx is installed in different Python version. It confuses and doesn't warn for its Python version.How was this patch tested?
Manually tested:
python(Python 2.7) in the path with Sphinx:python(Python 2.7) in the path without Sphinx:SPHINXPYTHONsetpython(Python 2.7) with Sphinx:SPHINXPYTHONsetpython(Python 2.7) without Sphinx:SPHINXPYTHONsetpython3with Sphinx:SPHINXPYTHONsetpython3without Sphinx:SPHINXBUILDset:Both
SPHINXPYTHONandSPHINXBUILDare set: