Skip to content

Commit 0fbe7e7

Browse files
authored
ARROW-215 Add tox config (#195)
* ARROW-215 Add tox config
1 parent cb0dc92 commit 0fbe7e7

File tree

15 files changed

+202
-86
lines changed

15 files changed

+202
-86
lines changed

.github/workflows/benchmark.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,36 @@ jobs:
3232
uses: supercharge/[email protected]
3333
with:
3434
mongodb-version: 6.0
35-
- name: Install libbson
35+
- name: Install tox
3636
run: |
37-
LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh
38-
- name: Install Python dependencies
37+
python -m pip install tox
38+
- name: Install libbson
3939
run: |
40-
python -m pip install -U pip
41-
python -m pip install asv virtualenv
40+
tox -e build-libbson
4241
4342
- name: Run benchmarks
4443
run: |
4544
set -eux
4645
run_asv () {
47-
if [ ! -e "asv.conf.json" ] ; then
48-
git checkout refs/bm/pr asv.conf.json
49-
git checkout refs/bm/pr benchmarks/__init__.py
50-
git checkout refs/bm/pr benchmarks/benchmarks.py
46+
if [ ! -e "tox.ini" ] ; then
47+
git checkout refs/bm/pr tox.ini
5148
fi
5249
git show --no-patch --format="%H (%s)"
53-
asv run -e --python=`which python` --set-commit-hash $(git rev-parse HEAD)
50+
export LIBBSON_INSTALL_DIR=$(pwd)/libbson
51+
tox -e benchmark -- --set-commit-hash $(git rev-parse HEAD)
5452
}
5553
54+
pip install asv
5655
asv machine --yes
5756
git fetch origin main:main
5857
git update-ref refs/bm/pr HEAD
5958
# We know this is a PR run. The branch is a GitHub refs/pull/*/merge ref, so
6059
# the current target that this PR will be merged into is HEAD^1.
6160
git update-ref refs/bm/merge-target $(git log -n 1 --pretty=format:"%H" main --)
6261
git checkout --force refs/bm/pr --
63-
# Install the library
64-
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e ".[test]"
6562
run_asv
6663
67-
6864
git checkout --force refs/bm/merge-target --
69-
# Install the library
70-
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e ".[test]"
7165
run_asv
7266
7367
- name: Compare benchmarks

.github/workflows/release-python.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,17 @@ jobs:
116116
# Build sdist on lowest supported Python
117117
python-version: '3.8'
118118

119+
- name: Install tox
120+
run: |
121+
python -m pip install tox
122+
119123
- name: Build SDist
120124
working-directory: ./bindings/python
121125
run: |
122126
set -ex
123-
python -m pip install -U pip build
124127
export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
125-
./build-libbson.sh
126-
python -m build --sdist .
128+
tox -e build-libbson
129+
tox -e build-dist -- --sdist
127130
128131
- name: Test Sdist
129132
working-directory: ./bindings/python

.github/workflows/test-python.yml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,22 @@ jobs:
6969
mongod --remove
7070
mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
7171
net start MongoDB
72-
- name: Install libbson
73-
run: |
74-
pip install packaging # needed for mongo-c-driver-1.24.4/build/calc_release_version.py
75-
pip install setuptools # needed for use of distutils
76-
./build-libbson.sh
77-
- name: Install Python dependencies
72+
- name: Install tox
7873
run: |
79-
python -m pip install -U pip
80-
- name: Install pymongoarrow
74+
python -m pip install tox
75+
- name: Install libbson
8176
run: |
82-
# Install the library with no deps
83-
python -m pip install -v -e "."
77+
tox -e build-libbson
8478
- name: Ensure imports with no test deps
8579
run: |
86-
python -c "from pymongoarrow.monkey import patch_all; patch_all()"
87-
- name: Install the test dependencies
88-
run: |
89-
python -m pip install -v -e ".[test]"
80+
echo "LIBBSON_INSTALL_DIR=$LIBBSON_INSTALL_DIR"
81+
tox -e import-check
9082
- name: Run the tests
9183
run: |
92-
PYTHONWARNINGS=error python -m pytest -s -vv
84+
tox -e test
9385
- name: Check the manifest
9486
run: |
95-
pip install check-manifest
96-
check-manifest -v
87+
tox -e manifest
9788
9889
docs:
9990
runs-on: ubuntu-latest
@@ -105,17 +96,14 @@ jobs:
10596
python-version: 3.9
10697
cache: 'pip'
10798
cache-dependency-path: '**/pyproject.toml'
108-
- name: Install lib
109-
shell: bash -l {0}
99+
- name: Install tox
110100
run: |
111-
NO_EXT=1 pip install .[docs]
112-
- name: Build docs with warnings
101+
python -m pip install tox
102+
- name: Build docs
113103
shell: bash -l {0}
114104
run: |
115-
pushd docs
116-
make html SPHINXOPTS="-W"
105+
NO_EXT=1 tox -e docs
117106
- name: Run linkcheck
118107
shell: bash -l {0}
119108
run: |
120-
pushd docs
121-
make linkcheck
109+
NO_EXT=1 tox -e linkcheck

.readthedocs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ build:
44
tools:
55
python: "3.9"
66
commands:
7-
- NO_EXT=1 pip install ./bindings/python[docs]
7+
- NO_EXT=1 pip install ./bindings/python
8+
- pip install -r ./bindings/python/docs/docs-requirements.txt
89
- mkdir --parents $READTHEDOCS_OUTPUT/html/
910
- cd ./bindings/python/docs && make html
1011
- cp --recursive ./bindings/python/docs/build/html/* $READTHEDOCS_OUTPUT/html/

bindings/python/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include README.md
22
include LICENSE
33
include *.sh
44
include pyproject.toml
5+
include tox.ini
56

67
exclude THIRD-PARTY-NOTICES
78
exclude addtags.py

bindings/python/build-libbson.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ then
2020
fi
2121

2222
echo "Installing libbson..."
23-
23+
DEFAULT_ARCH=$(uname -m)
2424
MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.15"}
25-
CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES:-"x86_64"}
25+
CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES:-${DEFAULT_ARCH}}
2626
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-"Debug"}
2727

2828
# Directory where build artifacts will be placed
29-
LIBBSON_INSTALL_DIR=${LIBBSON_INSTALL_DIR:-""}
29+
DEFAULT_INSTALL_DIR=$(pwd)/libbson
30+
LIBBSON_INSTALL_DIR=${LIBBSON_INSTALL_DIR:-${DEFAULT_INSTALL_DIR}}
3031

3132
# Replace a relative path with an absolute one for cmake
3233
LIBBSON_INSTALL_DIR="$(cd "$(dirname "$LIBBSON_INSTALL_DIR")"; pwd)/$(basename "$LIBBSON_INSTALL_DIR")"

bindings/python/cibw_before_build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ then
1515
export CMAKE_OSX_ARCHITECTURES="arm64"
1616
else
1717
platform="macosx_10_14_x86_64"
18+
export CMAKE_OSX_ARCHITECTURES="x86_64"
1819
fi
1920

2021
# Install pyarrow with the appropriate platform.
2122
pip install --platform $platform --upgrade --target $HOME/wheels --no-deps --only-binary=:all: pyarrow
2223
fi
2324

25+
# Install tox, needed for the build command.
26+
pip install tox
27+
2428
# Build libbson with the appropriate arch.
25-
CMAKE_BUILD_TYPE=Release ./build-libbson.sh
29+
CMAKE_BUILD_TYPE=Release tox -e build-libbson
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sphinx>=5.3,<8
2+
sphinx_rtd_theme>=2,<3
3+
sphinxcontrib-shellcheck>=1,<2
4+
furo==2023.9.10

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ To run the benchmarks, you need the `asv <https://pypi.org/project/asv/>`_ packa
1010
which can then be invoked like so::
1111

1212
$ asv run --strict --python=`which python`
13+
14+
or you can run with tox as:
15+
16+
$ tox -e benchmarks

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ from sources::
2929

3030
$ virtualenv pymongoarrow
3131
$ source ./pymongoarrow/bin/activate
32+
$ pip install tox
3233

3334
libbson
3435
^^^^^^^
@@ -41,7 +42,7 @@ Detailed instructions for building/installing ``libbson`` can be found
4142
You can either use a system-provided version of ``libbson`` that is properly
4243
configured for use with ``pkg-config``, or use the provided ``build-libbson.sh`` script to build it::
4344

44-
$ LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh
45+
$ LIBBSON_INSTALL_DIR=$(pwd)/libbson tox -e build-libbson
4546

4647
On macOS, users can install the latest ``libbson`` using Homebrew::
4748

@@ -57,22 +58,29 @@ If you try to build with a lower version a ``ValueError`` will be raised.
5758
Build
5859
-----
5960

60-
In the previously created virtualenv, install PyMongoArrow and its test dependencies in editable mode::
61+
Typically we will use the provided ``tox`` scripts and will not build directly, but you can build and
62+
test in the created virtualenv.
63+
64+
In the previously created virtualenv, to install PyMongoArrow and its test dependencies in editable mode::
6165

6266
(pymongoarrow) $ pip install -v -e ".[test]"
6367

6468
If you built libbson using the ``build-libbson`` script then use the same ``LIBBSON_INSTALL_DIR`` as above:
6569

6670
(pymongoarrow) $ LIBBSON_INSTALL_DIR=$(pwd)/libbson pip install -v -e ".[test]"
6771

68-
6972
Test
7073
----
7174

7275
To run the test suite, you will need a MongoDB instance running on
7376
``localhost`` using port ``27017``. To run the entire test suite, do::
7477

75-
(pymongoarrow) $ python -m pytest
78+
(pymongoarrow) $ tox -e test
79+
80+
or, if not using ``tox``:
81+
82+
(pymongoarrow) $ pytest
83+
7684

7785
Running Linters
7886
---------------
@@ -84,9 +92,9 @@ that help follow a consistent code style within the codebase.
8492

8593
To set up ``pre-commit`` locally, run::
8694

87-
pip install pre-commit
88-
pre-commit install
95+
(pymongoarrow) $ pip install pre-commit
96+
(pymongoarrow) $ pre-commi t install
8997

9098
To run ``pre-commit`` manually, run::
9199

92-
pre-commit run --all-files
100+
(pymongoarrow) $ tox -e lint

0 commit comments

Comments
 (0)