AlenkaF commented on code in PR #35907:
URL: https://github.com/apache/arrow/pull/35907#discussion_r1219532643
##########
docs/source/conf.py:
##########
@@ -38,15 +38,63 @@
from unittest import mock
from docutils.parsers.rst import Directive, directives
-import pyarrow
-
-
sys.path.extend([
os.path.join(os.path.dirname(__file__),
'..', '../..')
])
+# -- Customization --------------------------------------------------------
+
+try:
+ import pyarrow
+ exclude_patterns = []
+
+ # Conditional API doc generation
+
+ # Sphinx has two features for conditional inclusion:
+ # - The "only" directive
+ #
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags
+ # - The "ifconfig" extension
+ # https://www.sphinx-doc.org/en/master/usage/extensions/ifconfig.html
+ #
+ # Both have issues, but "ifconfig" seems to work in this setting.
+
+ try:
+ import pyarrow.cuda
+ cuda_enabled = True
+ except ImportError:
+ cuda_enabled = False
+ # Mock pyarrow.cuda to avoid autodoc warnings.
+ # XXX I can't get autodoc_mock_imports to work, so mock manually
instead
+ #
(https://github.com/sphinx-doc/sphinx/issues/2174#issuecomment-453177550)
+ pyarrow.cuda = sys.modules['pyarrow.cuda'] = mock.Mock()
+
+ try:
+ import pyarrow.flight
+ flight_enabled = True
+ except ImportError:
+ flight_enabled = False
+ pyarrow.flight = sys.modules['pyarrow.flight'] = mock.Mock()
+
+ try:
+ import pyarrow.orc
+ orc_enabled = True
+ except ImportError:
+ orc_enabled = False
+ pyarrow.orc = sys.modules['pyarrow.orc'] = mock.Mock()
+
+ try:
+ import pyarrow.parquet.encryption
+ parquet_encryption_enabled = True
+ except ImportError:
+ parquet_encryption_enabled = False
+ pyarrow.parquet.encryption = sys.modules['pyarrow.parquet.encryption']
= mock.Mock()
+except:
Review Comment:
There is actually `LookupError` raised first:
```
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/Users/alenkafrim/repos/arrow/python/pyarrow/__init__.py", line 40,
in <module>
from ._generated_version import version as __version__
ModuleNotFoundError: No module named 'pyarrow._generated_version'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"/Users/alenkafrim/repos/pyarrow-dev/lib/python3.10/site-packages/sphinx/config.py",
line 350, in eval_config_file
exec(code, namespace)
File "/Users/alenkafrim/repos/arrow/docs/source/conf.py", line 50, in
<module>
import pyarrow
File "/Users/alenkafrim/repos/arrow/python/pyarrow/__init__.py", line 56,
in <module>
__version__ = setuptools_scm.get_version('../',
File
"/Users/alenkafrim/repos/pyarrow-dev/lib/python3.10/site-packages/setuptools_scm/__init__.py",
line 148, in get_version
_version_missing(config)
File
"/Users/alenkafrim/repos/pyarrow-dev/lib/python3.10/site-packages/setuptools_scm/__init__.py",
line 108, in _version_missing
raise LookupError(
LookupError: setuptools-scm was unable to detect version for
/Users/alenkafrim/repos/arrow/docs.
Make sure you're either building from a fully intact git repository or PyPI
tarballs. Most other sources (such as GitHub's tarballs, a git checkout without
the .git folder) don't contain the necessary metadata and will not work.
For example, if you're using pip, instead of
https://github.com/user/proj/archive/master.zip use
git+https://github.com/user/proj.git#egg=proj
make: *** [html] Error 2
```
Will do `except LookupError:`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]