Skip to content

Commit 6c2a502

Browse files
authored
INTPYTHON-592 Convert to use just and uv (#298)
1 parent a984af8 commit 6c2a502

25 files changed

+1797
-282
lines changed

.github/workflows/benchmark.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,20 @@ jobs:
3434
uses: supercharge/[email protected]
3535
with:
3636
mongodb-version: 6.0
37-
- name: Install tox
37+
- name: Install deps
3838
run: |
39-
python -m pip install tox
39+
python -m pip install rust-just uv
4040
- name: Install libbson
4141
run: |
42-
tox -e build-libbson
42+
just build-libbson
4343
4444
- name: Run benchmarks
4545
run: |
4646
set -eux
4747
run_asv () {
48-
if [ ! -e "tox.ini" ] ; then
49-
git checkout refs/bm/pr tox.ini
50-
fi
5148
git show --no-patch --format="%H (%s)"
5249
export LIBBSON_INSTALL_DIR=$(pwd)/libbson
53-
tox -e benchmark -- --set-commit-hash $(git rev-parse HEAD)
50+
just benchmark --set-commit-hash $(git rev-parse HEAD)
5451
}
5552
5653
pip install asv virtualenv

.github/workflows/dist-python.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ jobs:
7777
if: runner.os == 'macOS'
7878
run: brew install pkg-config
7979

80-
- name: Install cibuildwheel
81-
run: python -m pip install "cibuildwheel>=2.4,<3"
80+
- name: Install deps
81+
run: python -m pip install "cibuildwheel>=2.4,<3" uv rust-just
8282

8383
- name: Build MacOS Py39 Wheels
8484
if: ${{ matrix.python == 'cp39' && matrix.buildplat[0] == 'macos-11' }}
@@ -114,22 +114,21 @@ jobs:
114114
# Build sdist on lowest supported Python
115115
python-version: '3.9'
116116

117-
- name: Install tox
117+
- name: Install deps
118118
run: |
119-
python -m pip install tox
119+
python -m pip install rust-just uv build
120120
121121
- name: Build SDist
122122
working-directory: ./bindings/python
123123
run: |
124-
set -ex
125-
export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
126-
tox -e build-libbson
127-
tox -e build-dist -- --sdist
124+
export LIBBSON_INSTALL_DIR=$(pwd)/libbson
125+
just build-libbson
126+
python -m build --sdist .
128127
129128
- name: Test Sdist
130129
working-directory: ./bindings/python
131130
run: |
132-
export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
131+
export LIBBSON_INSTALL_DIR=$(pwd)/libbson
133132
python -m pip install dist/*.gz
134133
cd ..
135134
python -c "from pymongoarrow.lib import libbson_version"

.github/workflows/release-python.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,13 @@ jobs:
5151
aws_region_name: ${{ vars.AWS_REGION_NAME }}
5252
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
5353
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
54-
- name: Install tox
54+
- name: Install Deps
5555
run: |
56-
python -m pip install tox
56+
python -m pip install rust-just uv
5757
- name: Build Libbson
5858
working-directory: ./bindings/python
5959
run: |
60-
set -ex
61-
export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
62-
tox -e build-libbson
60+
just build-libbson
6361
echo "LIBBSON_INSTALL_DIR=$LIBBSON_INSTALL_DIR" >> $GITHUB_ENV
6462
- uses: mongodb-labs/drivers-github-tools/python-labs/pre-publish@v2
6563
id: pre-publish

.github/workflows/test-python.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ defaults:
1616

1717
jobs:
1818

19-
pre-commit:
20-
name: pre-commit
19+
lint:
20+
name: lint
2121
runs-on: ubuntu-latest
2222

2323
steps:
2424
- uses: actions/checkout@v4
2525
with:
2626
persist-credentials: false
2727
- uses: actions/setup-python@v5
28-
- uses: pre-commit/[email protected]
29-
with:
30-
extra_args: --all-files --hook-stage=manual
28+
- name: Install Deps
29+
run: |
30+
python -m pip install rust-just uv
31+
- name: Run linter
32+
run: just lint
3133

3234
build:
3335
# supercharge/mongodb-github-action requires containers so we don't test other platforms
@@ -76,22 +78,15 @@ jobs:
7678
mongod --remove
7779
mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
7880
net start MongoDB
79-
- name: Install tox
81+
- name: Install Deps
8082
run: |
81-
python -m pip install tox
83+
python -m pip install rust-just uv
8284
- name: Install libbson
83-
run: |
84-
tox -e build-libbson
85+
run: just build-libbson
8586
- name: Ensure imports with no test deps
86-
run: |
87-
echo "LIBBSON_INSTALL_DIR=$LIBBSON_INSTALL_DIR"
88-
tox -e import-check
87+
run: just import-check
8988
- name: Run the tests
90-
run: |
91-
tox -e test
92-
- name: Check the manifest
93-
run: |
94-
tox -e manifest
89+
run: just test
9590

9691
docs:
9792
runs-on: ubuntu-latest
@@ -105,14 +100,10 @@ jobs:
105100
python-version: 3.9
106101
cache: 'pip'
107102
cache-dependency-path: '**/pyproject.toml'
108-
- name: Install tox
103+
- name: Install Deps
109104
run: |
110-
python -m pip install tox
105+
python -m pip install rust-just uv
111106
- name: Build docs
112-
shell: bash -l {0}
113-
run: |
114-
NO_EXT=1 tox -e docs
107+
run: just docs
115108
- name: Run linkcheck
116-
shell: bash -l {0}
117-
run: |
118-
NO_EXT=1 tox -e linkcheck
109+
run: just docs-linkcheck

.readthedocs.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ version: 2
22
build:
33
os: ubuntu-22.04
44
tools:
5-
python: "3.9"
6-
commands:
7-
- NO_EXT=1 pip install ./bindings/python
8-
- pip install -r ./bindings/python/docs/docs-requirements.txt
9-
- mkdir --parents $READTHEDOCS_OUTPUT/html/
10-
- cd ./bindings/python/docs && make html
11-
- cp --recursive ./bindings/python/docs/build/html/* $READTHEDOCS_OUTPUT/html/
5+
python: "3.11"
6+
jobs:
7+
create_environment:
8+
- asdf plugin add uv
9+
- asdf install uv latest
10+
- asdf global uv latest
11+
install:
12+
- cd bindings/python && uv sync --no-install-project --group docs
13+
build:
14+
html:
15+
- cd bindings/python && uv run --no-project sphinx-build -c docs -T -b html docs $READTHEDOCS_OUTPUT/html

bindings/python/CONTRIBUTING.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ PyMongoArrow uses [Ruff](https://docs.astral.sh/ruff/) for formatting and lintin
2525
- Avoid backward breaking changes if at all possible.
2626
- Write inline documentation for new classes and methods.
2727
- Write tests and make sure they pass (make sure you have a mongod
28-
running on the default port, then execute `tox -e test` from the cmd
28+
running on the default port, then execute `just test` from the cmd
2929
line to run the test suite).
3030
- Add yourself to doc/contributors.rst `:)`
3131

@@ -144,18 +144,16 @@ Windows is not yet supported.
144144

145145
First, clone the mongo-arrow git repository:
146146

147-
``` bash
148-
$ git clone https://github.com/mongodb-labs/mongo-arrow.git
149-
$ cd mongo-arrow/bindings/python
147+
```bash
148+
git clone https://github.com/mongodb-labs/mongo-arrow.git
149+
cd mongo-arrow/bindings/python
150150
```
151151

152-
Additionally, create a virtualenv in which to install `pymongoarrow`
153-
from sources:
152+
Ensure you have [just](https://just.systems/man/en/introduction.html) and [uv](https://docs.astral.sh/uv/getting-started/installation/) installed.
153+
Then run:
154154

155-
``` bash
156-
$ virtualenv pymongoarrow
157-
$ source ./pymongoarrow/bin/activate
158-
$ pip install tox
155+
```bash
156+
just install
159157
```
160158

161159
### libbson
@@ -170,7 +168,7 @@ properly configured for use with `pkg-config`, or use the provided
170168
`build-libbson.sh` script to build it:
171169

172170
``` bash
173-
$ LIBBSON_INSTALL_DIR=$(pwd)/libbson tox -e build-libbson
171+
just build-libbson
174172
```
175173

176174
On macOS, users can install the latest `libbson` using Homebrew:
@@ -190,14 +188,14 @@ you try to build with a lower version a `ValueError` will be raised.
190188

191189
## Build
192190

193-
Typically we will use the provided `tox` scripts and will not build
191+
Typically we will use the provided `just` scripts and will not build
194192
directly, but you can build and test in the created virtualenv.
195193

196194
In the previously created virtualenv, to install PyMongoArrow and its
197195
test dependencies in editable mode:
198196

199-
``` bash
200-
(pymongoarrow) $ pip install -v -e ".[test]"
197+
```bash
198+
pip install -v -e ".[test]"
201199
```
202200

203201
If you built libbson using the `build-libbson` script then use the same
@@ -211,11 +209,11 @@ If you built libbson using the `build-libbson` script then use the same
211209
To run the test suite, you will need a MongoDB instance running on
212210
`localhost` using port `27017`. To run the entire test suite, do:
213211

214-
``` bash
215-
(pymongoarrow) $ tox -e test
212+
```bash
213+
just test
216214
```
217215

218-
or, if not using `tox`:
216+
or, if not using `just`:
219217

220218
> (pymongoarrow) \$ pytest
221219
@@ -228,15 +226,14 @@ consistent code style within the codebase.
228226

229227
To set up `pre-commit` locally, run:
230228

231-
``` bash
232-
(pymongoarrow) $ pip install pre-commit
233-
(pymongoarrow) $ pre-commit install
229+
```bash
230+
just install
234231
```
235232

236233
To run `pre-commit` manually, run:
237234

238-
``` bash
239-
(pymongoarrow) $ tox -e lint
235+
```bash
236+
just lint
240237
```
241238

242239
## Running Benchmarks
@@ -246,12 +243,12 @@ To run `pre-commit` manually, run:
246243
To run the benchmarks, you need the [asv](https://pypi.org/project/asv/)
247244
package, which can then be invoked like so:
248245

249-
``` bash
246+
```bash
250247
asv run --strict --python=`which python`
251248
```
252249

253-
or you can run with tox as:
250+
or you can run with just as:
254251

255-
``` bash
256-
tox -e benchmarks
252+
```bash
253+
just benchmark
257254
```

bindings/python/MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ include LICENSE
55
include THIRD-PARTY-NOTICES
66
include *.sh
77
include pyproject.toml
8-
include tox.ini
98

109
exclude RELEASE.md
1110
exclude asv.conf.json
11+
exclude uv.lock
12+
exclude justfile
1213

1314
graft pymongoarrow
1415

bindings/python/build-libbson.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}"
3636
echo "CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}"
3737
echo "LIBBSON_INSTALL_DIR=${LIBBSON_INSTALL_DIR}"
3838

39+
# Activate the virtualenv for the cmake build.
40+
if [ -d "$(pwd)/.venv/Scripts" ]; then
41+
. "$(pwd)/.venv/Scripts/activate"
42+
else
43+
. "$(pwd)/.venv/bin/activate"
44+
fi
45+
3946
# Build libbson
4047
pushd "$WORKDIR"
4148
git checkout "$LIBBSON_VERSION"

bindings/python/cibw_before_build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ then
2222
pip install --platform $platform --upgrade --target $HOME/wheels --no-deps --only-binary=:all: pyarrow
2323
fi
2424

25-
# Install tox, needed for the build command.
26-
pip install tox
25+
# Install just uv, needed for the build command.
26+
pip install rust-just uv
2727

2828
# Build libbson with the appropriate arch.
29-
CMAKE_BUILD_TYPE=Release tox -e build-libbson
29+
CMAKE_BUILD_TYPE=Release just build-libbson

bindings/python/docs/Makefile

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

0 commit comments

Comments
 (0)