Skip to content

Commit a5fc0ba

Browse files
authored
PYTHON-3047 Clean up handling of pyarrow library (#39)
1 parent 85410c9 commit a5fc0ba

File tree

11 files changed

+148
-105
lines changed

11 files changed

+148
-105
lines changed

.github/workflows/test-python.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
pull_request:
66

7+
defaults:
8+
run:
9+
working-directory: ./bindings/python
10+
711
jobs:
812
build:
913
# supercharge/mongodb-github-action requires containers so we don't test other platforms
@@ -27,21 +31,17 @@ jobs:
2731
- name: Install libbson
2832
run: |
2933
LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh
30-
working-directory: ./bindings/python
3134
- name: Install Python dependencies
3235
run: |
33-
python -m pip install -U pip wheel
34-
python -m pip install -r requirements/test.txt
35-
python -c 'import pyarrow as pa; pa.create_library_symlinks()'
36-
working-directory: ./bindings/python
36+
python -m pip install -U pip
3737
- name: Install pymongoarrow
3838
run: |
39-
# Use pip install to pull in install_requires dependencies
40-
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e .
41-
# Re-compile to see compiler/linker output in the logs
42-
LIBBSON_INSTALL_DIR=$(pwd)/libbson python setup.py build_ext --inplace --force
43-
working-directory: ./bindings/python
39+
# Install the library
40+
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -vvv -e ".[test]"
4441
- name: Run tests
4542
run: |
4643
LD_LIBRARY_PATH=$(pwd)/libbson/lib python -m unittest discover test -v
47-
working-directory: ./bindings/python
44+
- name: Check the manifest
45+
run: |
46+
pip install check-manifest
47+
check-manifest -v

bindings/python/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ __pycache__/
55

66
# C extensions
77
*.so
8+
*.dylib
89

910
# Distribution / packaging
1011
.Python

bindings/python/MANIFEST.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
include README.rst
22
include LICENSE
33
include build-libbson.sh
4-
include release.sh
4+
include pyproject.toml
5+
6+
exclude THIRD-PARTY-NOTICES
7+
exclude release.sh
8+
exclude addtags.py
9+
exclude benchmark.py
510

611
graft pymongoarrow
712

8-
prune test
13+
recursive-exclude test *
14+
recursive-exclude docs *
915

1016
global-exclude *.cpp
1117
global-exclude *.dylib
18+
global-exclude *.so.*
1219
global-exclude *.so
1320
global-exclude *.pyc
1421
global-exclude .git*

bindings/python/docs/source/developer/installation.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,22 @@ On macOS, users can install the latest ``libbson`` via Homebrew::
4141

4242
$ brew install mongo-c-driver
4343

44+
Alternatively, you can use the provided `build-libbson.sh` script to build it::
45+
46+
$ LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh
47+
4448

4549
Build
4650
-----
4751

48-
In the previously created virtualenv, we first install all build and test dependencies
49-
of PyMongoArrow::
52+
In the previously created virtualenv, install PyMongoArrow and its test dependencies in editable mode::
5053

51-
(pymongoarrow) $ pip install -r requirements/test.txt
54+
(pymongoarrow) $ pip install -v -e ".[test]"
5255

53-
We also need the pyarrow library symlinks, which can be created as follows::
54-
55-
(pymongoarrow) $ python -c 'import pyarrow as pa; pa.create_library_symlinks()'
56+
If you built libbson using the `build-libbson` script then use the same `LIBBSON_INSTALL_DIR` as above:
5657

57-
We can now install ``pymongoarrow`` in **development mode** as follows::
58+
(pymongoarrow) $ LIBBSON_INSTALL_DIR=$(pwd)/libbson pip install -v -e ".[test]"
5859

59-
(pymongoarrow) $ python setup.py build_ext --inplace
60-
(pymongoarrow) $ python setup.py develop
6160

6261
Test
6362
----

bindings/python/pymongoarrow/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
# We must import pyarrow before attempting to load the Cython module.
1616
import pyarrow
1717

18-
from pymongoarrow.lib import libbson_version
1918
from pymongoarrow.version import __version__, _MIN_LIBBSON_VERSION
20-
19+
# This line must come second so setuptools can parse the __version__
20+
# above without having a built application.
21+
from pymongoarrow.lib import libbson_version
2122

2223
try:
2324
from pkg_resources import parse_version as _parse_version

bindings/python/pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=47.9",
4+
"wheel>=0.37",
5+
"cython>=0.29",
6+
# Must be kept in sync with the `install_requires` in `setup.cfg`
7+
"pyarrow>=6.0.0,<6.1.0",
8+
]
9+
10+
[tool.check-manifest]
11+
ignore = [
12+
"pymongoarrow/*.so*.*",
13+
"pymongoarrow/*.so*",
14+
"pymongoarrow/*.dylib"
15+
]

bindings/python/release.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ $PYTHON --version
3838
cp $LIBBSON_INSTALL_DIR/lib*/$LIBBSON_SO "$(pwd)/pymongoarrow/"
3939

4040
# Install build dependencies
41-
$PYTHON -m pip install -U pip wheel
42-
$PYTHON -m pip install -r requirements/build.txt
43-
44-
# https://arrow.apache.org/docs/python/extending.html#building-extensions-against-pypi-wheels
45-
$PYTHON -c "import pyarrow; pyarrow.create_library_symlinks()"
41+
$PYTHON -m pip install -U pip build
4642

4743
# Build wheels in $(pwd)/dist/*.whl
48-
LIBBSON_INSTALL_DIR="$LIBBSON_INSTALL_DIR" $PYTHON setup.py bdist_wheel
44+
LIBBSON_INSTALL_DIR="$LIBBSON_INSTALL_DIR" $PYTHON -m build --wheel .
4945

5046
# Run auditwheel repair to set platform tags on Linux
5147
if [ "Linux" = "$(uname -s)" ]

bindings/python/requirements/build.txt

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

bindings/python/requirements/test.txt

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

bindings/python/setup.cfg

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
[metadata]
3+
name = pymongoarrow
4+
version = attr: pymongoarrow.version.__version__
5+
description = "Tools for using NumPy, Pandas and PyArrow with MongoDB"
6+
long_description = file: README.rst
7+
long_description_content_type = text/x-rst
8+
license = Apache License, Version 2.0
9+
author = Prashant Mital
10+
maintainer = MongoDB, Inc.
11+
url = https://github.com/mongodb-labs/mongo-arrow/tree/main/bindings/python
12+
platforms = Linux, Mac OS X
13+
keywords = mongo, mongodb, pymongo, arrow, bson, numpy, pandas
14+
classifiers =
15+
Development Status :: 3 - Alpha
16+
Intended Audience :: Developers
17+
Intended Audience :: Science/Research
18+
License :: OSI Approved :: Apache Software License
19+
Operating System :: MacOS :: MacOS X
20+
Operating System :: POSIX
21+
Programming Language :: Python :: 3
22+
Programming Language :: Python :: 3 :: Only
23+
Programming Language :: Python :: 3.6
24+
Programming Language :: Python :: 3.7
25+
Programming Language :: Python :: 3.8
26+
Programming Language :: Python :: 3.9
27+
Programming Language :: Python :: 3.10
28+
Programming Language :: Python :: Implementation :: CPython
29+
Topic :: Database
30+
31+
[options]
32+
zip_safe = False
33+
include_package_data = True
34+
packages = find:
35+
python_requires = >=3.6
36+
install_requires =
37+
# keep versions in sync with pyproject.toml "requires"
38+
pyarrow >=6,<6.1
39+
pymongo >=3.11,<5
40+
41+
[options.package_data]
42+
pymongoarrow = *.pxd, *.pyx, *.pyi, *.so.*, *.dylib
43+
44+
[options.packages.find]
45+
exclude =
46+
test
47+
docs
48+
49+
[options.extras_require]
50+
test = pandas;pytz

0 commit comments

Comments
 (0)