Skip to content

Commit 05a2199

Browse files
authored
ARROW-184 API Docs are not rendered in Latest Docs (#172)
* ARROW-184 API Docs are not rendered in Latest Docs * fix config * update config * update config * update config * use gxx * include pyarrow in conda env * fix config * fix config * make c extensions optional for docs * use a default libbson version * fix html handling * more docs fixes * more docs fixes * more docs fixes * more docs fixes * more docs fixes * more docs fixes * more docs fixes * try again * update comment * undo changes * undo change * undo change
1 parent c6dd78b commit 05a2199

File tree

7 files changed

+73
-66
lines changed

7 files changed

+73
-66
lines changed

.github/workflows/test-python.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
with:
4444
python-version: ${{ matrix.python-version }}
4545
cache: 'pip'
46-
cache-dependency-path: '**/setup.cfg'
46+
cache-dependency-path: '**/pyproject.toml'
4747
- name: Set up env
4848
run: |
4949
echo "LIBBSON_INSTALL_DIR=$PWD/libbson" >> $GITHUB_ENV
@@ -98,26 +98,16 @@ jobs:
9898
runs-on: ubuntu-latest
9999
steps:
100100
- uses: actions/checkout@v4
101-
- name: Cache conda
102-
uses: actions/cache@v3
103-
env:
104-
# Increase this value to reset cache if environment.yml has not changed
105-
CACHE_NUMBER: 0
106-
with:
107-
path: ~/conda_pkgs_dir
108-
key:
109-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
110-
hashFiles('bindings/python/docs/environment.yml') }}
111-
- uses: conda-incubator/setup-miniconda@v2
101+
- name: Setup Python
102+
uses: actions/setup-python@v4
112103
with:
113-
auto-update-conda: true
114-
activate-environment: mongo_arrow_documentation
115-
environment-file: bindings/python/docs/environment.yml
116-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
104+
python-version: 3.9
105+
cache: 'pip'
106+
cache-dependency-path: '**/pyproject.toml'
117107
- name: Install lib
118108
shell: bash -l {0}
119109
run: |
120-
pip install .
110+
NO_EXT=1 pip install .[docs]
121111
- name: Build docs with warnings
122112
shell: bash -l {0}
123113
run: |

.readthedocs.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
2-
sphinx:
3-
configuration: ./bindings/python/docs/source/conf.py
4-
conda:
5-
environment: ./bindings/python/docs/environment.yml
6-
python:
7-
install:
8-
# install the package itself
9-
- method: pip
10-
path: ./bindings/python
2+
build:
3+
os: ubuntu-22.04
4+
tools:
5+
python: "3.9"
6+
commands:
7+
- NO_EXT=1 pip install ./bindings/python[docs]
8+
- mkdir --parents $READTHEDOCS_OUTPUT/html/
9+
- cd ./bindings/python/docs && make html
10+
- cp --recursive ./bindings/python/docs/build/html/* $READTHEDOCS_OUTPUT/html/

bindings/python/docs/environment.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

bindings/python/pymongoarrow/api.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@
2626
from pymongo.common import MAX_WRITE_BATCH_SIZE
2727
from pymongoarrow.context import PyMongoArrowContext
2828
from pymongoarrow.errors import ArrowWriteError
29-
from pymongoarrow.lib import process_bson_stream
3029
from pymongoarrow.result import ArrowWriteResult
3130
from pymongoarrow.schema import Schema
3231
from pymongoarrow.types import _validate_schema, get_numpy_type
3332

33+
try:
34+
from pymongoarrow.lib import process_bson_stream
35+
except ImportError:
36+
import traceback
37+
38+
warnings.warn(
39+
"Could not find compiled pymongoarrow.lib extension, please install "
40+
"from source or report the following traceback on the issue tracker:\n"
41+
f"{traceback.format_exc()}"
42+
)
43+
3444
__all__ = [
3545
"aggregate_arrow_all",
3646
"find_arrow_all",

bindings/python/pymongoarrow/context.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,47 @@
1313
# limitations under the License.
1414
from bson.codec_options import DEFAULT_CODEC_OPTIONS
1515
from pyarrow import Table, timestamp
16-
from pymongoarrow.lib import (
17-
BinaryBuilder,
18-
BoolBuilder,
19-
CodeBuilder,
20-
DatetimeBuilder,
21-
Decimal128Builder,
22-
DocumentBuilder,
23-
DoubleBuilder,
24-
Int32Builder,
25-
Int64Builder,
26-
ListBuilder,
27-
ObjectIdBuilder,
28-
StringBuilder,
29-
)
3016
from pymongoarrow.types import _BsonArrowTypes, _get_internal_typemap
3117

32-
_TYPE_TO_BUILDER_CLS = {
33-
_BsonArrowTypes.int32: Int32Builder,
34-
_BsonArrowTypes.int64: Int64Builder,
35-
_BsonArrowTypes.double: DoubleBuilder,
36-
_BsonArrowTypes.datetime: DatetimeBuilder,
37-
_BsonArrowTypes.objectid: ObjectIdBuilder,
38-
_BsonArrowTypes.decimal128: Decimal128Builder,
39-
_BsonArrowTypes.string: StringBuilder,
40-
_BsonArrowTypes.bool: BoolBuilder,
41-
_BsonArrowTypes.document: DocumentBuilder,
42-
_BsonArrowTypes.array: ListBuilder,
43-
_BsonArrowTypes.binary: BinaryBuilder,
44-
_BsonArrowTypes.code: CodeBuilder,
45-
}
18+
try:
19+
from pymongoarrow.lib import (
20+
BinaryBuilder,
21+
BoolBuilder,
22+
CodeBuilder,
23+
DatetimeBuilder,
24+
Decimal128Builder,
25+
DocumentBuilder,
26+
DoubleBuilder,
27+
Int32Builder,
28+
Int64Builder,
29+
ListBuilder,
30+
ObjectIdBuilder,
31+
StringBuilder,
32+
)
33+
34+
_TYPE_TO_BUILDER_CLS = {
35+
_BsonArrowTypes.int32: Int32Builder,
36+
_BsonArrowTypes.int64: Int64Builder,
37+
_BsonArrowTypes.double: DoubleBuilder,
38+
_BsonArrowTypes.datetime: DatetimeBuilder,
39+
_BsonArrowTypes.objectid: ObjectIdBuilder,
40+
_BsonArrowTypes.decimal128: Decimal128Builder,
41+
_BsonArrowTypes.string: StringBuilder,
42+
_BsonArrowTypes.bool: BoolBuilder,
43+
_BsonArrowTypes.document: DocumentBuilder,
44+
_BsonArrowTypes.array: ListBuilder,
45+
_BsonArrowTypes.binary: BinaryBuilder,
46+
_BsonArrowTypes.code: CodeBuilder,
47+
}
48+
except ImportError:
49+
import traceback
50+
import warnings
51+
52+
warnings.warn(
53+
"Could not find compiled pymongoarrow.lib extension, please install "
54+
"from source or report the following traceback on the issue tracker:\n"
55+
f"{traceback.format_exc()}"
56+
)
4657

4758

4859
class PyMongoArrowContext:

bindings/python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ content-type = "text/x-rst"
4747
Homepage = "https://github.com/mongodb-labs/mongo-arrow/tree/main/bindings/python"
4848

4949
[project.optional-dependencies]
50+
docs = ["sphinx"]
5051
test = ["pytz", "pytest"]
5152

5253
[tool.setuptools]

bindings/python/setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,9 @@ def get_extension_modules():
172172
return modules
173173

174174

175-
setup(ext_modules=get_extension_modules())
175+
if os.environ.get("NO_EXT"):
176+
ext_modules = []
177+
else:
178+
ext_modules = get_extension_modules()
179+
180+
setup(ext_modules=ext_modules)

0 commit comments

Comments
 (0)