Skip to content

Commit 5aa42d4

Browse files
authored
PYTHON-2691 Add Windows support (#42)
1 parent 974b25a commit 5aa42d4

File tree

10 files changed

+141
-79
lines changed

10 files changed

+141
-79
lines changed

.github/workflows/release-python-osx.yml renamed to .github/workflows/release-python.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ on:
55
pull_request:
66

77
jobs:
8-
# MacOS
9-
build-osx-wheels:
8+
build-non-linux-wheels:
109
runs-on: ${{ matrix.os }}
1110
strategy:
1211
matrix:
13-
os: [macos-10.15]
12+
os: [macos-10.15, windows-latest]
1413
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
1514
name: Build CPython ${{ matrix.python-version }}-${{ matrix.os }}
1615
steps:
@@ -20,20 +19,21 @@ jobs:
2019
with:
2120
python-version: ${{ matrix.python-version }}
2221
- name: Build wheels
22+
working-directory: ./bindings/python
23+
shell: bash
2324
run: |
2425
./release.sh
25-
working-directory: ./bindings/python
2626
- uses: actions/upload-artifact@v2
2727
with:
2828
name: pymongoarrow-${{ matrix.python-version }}-${{ matrix.os }}-wheel
2929
path: ./bindings/python/dist/*.whl
3030
if-no-files-found: error
31-
test-osx-wheels:
32-
needs: build-osx-wheels
31+
test-non-linux-wheels:
32+
needs: build-non-linux-wheels
3333
runs-on: ${{ matrix.os }}
3434
strategy:
3535
matrix:
36-
os: [macos-10.15]
36+
os: [macos-10.15, windows-latest]
3737
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
3838
name: Test CPython ${{ matrix.python-version }}-${{ matrix.os }}
3939
steps:
@@ -46,6 +46,7 @@ jobs:
4646
with:
4747
name: pymongoarrow-${{ matrix.python-version }}-${{ matrix.os }}-wheel
4848
- name: Test wheel
49+
shell: bash
4950
run: |
5051
python -m pip install -U pip
5152
python -m pip install *.whl
@@ -63,9 +64,9 @@ jobs:
6364
steps:
6465
- uses: actions/checkout@v2
6566
- name: Build wheels
67+
working-directory: ./bindings/python
6668
run: |
6769
docker run --rm --volume `pwd`:/python --workdir /python --env PLAT=${{ matrix.container }} --env PYTHON_BINARY=/opt/python/${{ matrix.python-version }}/bin/python quay.io/pypa/${{ matrix.container }} ./release.sh
68-
working-directory: ./bindings/python
6970
- uses: actions/upload-artifact@v2
7071
with:
7172
name: pymongoarrow-${{ matrix.python-version }}-${{ matrix.container }}-wheel
@@ -91,12 +92,12 @@ jobs:
9192
# Collect all built wheels
9293
collect-wheels:
9394
runs-on: ubuntu-latest
94-
needs: [build-osx-wheels, build-manylinux-wheels]
95+
needs: [build-non-linux-wheels, build-manylinux-wheels]
9596
name: Download Wheels
9697
steps:
9798
- name: Download all workflow run artifacts
9899
uses: actions/download-artifact@v2
99100
- uses: actions/upload-artifact@v2
100101
with:
101102
name: nix-wheels
102-
path: "*-wheel"
103+
path: "*-wheel"

.github/workflows/test-python.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,43 @@ on:
77
defaults:
88
run:
99
working-directory: ./bindings/python
10+
shell: bash
1011

1112
jobs:
1213
build:
1314
# supercharge/mongodb-github-action requires containers so we don't test other platforms
1415
runs-on: ${{ matrix.os }}
1516
strategy:
1617
matrix:
17-
os: [ubuntu-20.04]
18+
os: ["ubuntu-20.04", "macos-latest", "windows-latest"]
1819
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
20+
fail-fast: false
1921
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
2022
steps:
2123
- uses: actions/checkout@v2
2224
- name: Setup Python
2325
uses: actions/setup-python@v2
2426
with:
2527
python-version: ${{ matrix.python-version }}
26-
- name: Start MongoDB
28+
- name: Start MongoDB on Linux
29+
if: ${{ startsWith(runner.os, 'Linux') }}
2730
uses: supercharge/[email protected]
2831
with:
2932
mongodb-version: 4.4
3033
mongodb-replica-set: test-rs
34+
- name: Start MongoDB on MacOS
35+
if: ${{ startsWith(runner.os, 'macOS') }}
36+
run: |
37+
mkdir data
38+
mongod --fork --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
39+
- name: Start MongoDB on Windows
40+
if: ${{ startsWith(runner.os, 'Windows') }}
41+
shell: powershell
42+
run: |
43+
mkdir data
44+
mongod --remove
45+
mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
46+
net start MongoDB
3147
- name: Install libbson
3248
run: |
3349
LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh

bindings/python/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ MANIFEST
3737

3838
# Sphinx documentation
3939
docs/_build/
40+
41+
# libbson files
42+
libbson
43+
mongo-c-driver-*

bindings/python/MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ global-exclude *.cpp
1717
global-exclude *.dylib
1818
global-exclude *.so.*
1919
global-exclude *.so
20+
global-exclude *.dll
21+
global-exclude *.pyd
2022
global-exclude *.pyc
2123
global-exclude .git*
2224
global-exclude .DS_Store

bindings/python/README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ PyMongoArrow is available on PyPI::
4949
To use PyMongoArrow with MongoDB Atlas' ``mongodb+srv://`` URIs, you will
5050
need to also install PyMongo with the ``srv`` extra::
5151

52-
$ python -m pip install 'pymongo[srv]<4' pymongoarrow
52+
$ python -m pip install 'pymongo[srv]' pymongoarrow
5353

5454
To use PyMongoArrow APIs that return query result sets as pandas
5555
DataFrame instances, you will also need to have the ``pandas`` package
5656
installed::
5757

5858
$ python -m pip install pandas
5959

60-
Currently, PyMongoArrow wheels are only available for macOS and Linux
61-
on x86_64 architectures.
62-
6360
Development Install
6461
===================
6562

66-
See the instructions on `Read the Docs <https://mongo-arrow.readthedocs.io/en/latest/developer/installation.html>`_.
63+
See the instructions on `Read the Docs`_.
6764

6865
Documentation
6966
=============
70-
Full documentation is available on `Read the Docs <https://mongo-arrow.readthedocs.io/en/latest/>`_.
67+
Full documentation is available on `Read the Docs`_.
68+
69+
70+
.. _Read the Docs: https://mongo-arrow.readthedocs.io/en/latest

bindings/python/pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,3 @@ requires = [
66
# Must be kept in sync with the `install_requires` in `setup.cfg`
77
"pyarrow>=6.0.0,<6.1.0",
88
]
9-
10-
[tool.check-manifest]
11-
ignore = [
12-
"pymongoarrow/*.so*.*",
13-
"pymongoarrow/*.so*",
14-
"pymongoarrow/*.dylib"
15-
]

bindings/python/release.sh

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,22 @@ then
1010
exit 1
1111
fi
1212

13-
# Build libbson binaries in $(pwd)/libbson
14-
LIBBSON_INSTALL_DIR="$(pwd)/libbson"
15-
1613
# Platform-dependent actions:
17-
# - Compute shared library name
18-
# - Set Python runtime to use
19-
if [ "Darwin" = "$(uname -s)" ]
20-
then
21-
LIBBSON_SO="libbson-1.0.0.dylib"
22-
PYTHON=${PYTHON_BINARY:-"python"}
23-
elif [ "Linux" = "$(uname -s)" ]
14+
PYTHON=${PYTHON_BINARY:-"python"}
15+
if [ "Linux" = "$(uname -s)" ]
2416
then
25-
LIBBSON_SO="libbson-1.0.so.0"
2617
PYTHON=${PYTHON_BINARY:-"python3"}
27-
else
28-
echo "Unsupported platform"
2918
fi
3019

20+
# Build libbson binaries in $(pwd)/libbson
21+
LIBBSON_INSTALL_DIR="$(pwd)/libbson"
22+
3123
# Build libbson
3224
LIBBSON_INSTALL_DIR="$LIBBSON_INSTALL_DIR" LIBBSON_VERSION=${LIBBSON_VERSION:-""} ./build-libbson.sh
3325

3426
# Print Python version used
3527
$PYTHON --version
3628

37-
# Vendor libbson shared library in PyMongoArrow wheels
38-
cp $LIBBSON_INSTALL_DIR/lib*/$LIBBSON_SO "$(pwd)/pymongoarrow/"
39-
4029
# Install build dependencies
4130
$PYTHON -m pip install -U pip build
4231

bindings/python/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ install_requires =
3939
pymongo >=3.11,<5
4040

4141
[options.package_data]
42-
pymongoarrow = *.pxd, *.pyx, *.pyi, *.so.*, *.dylib
42+
pymongoarrow = *.pxd, *.pyx, *.pyi, *.so.*, *.dylib, *.dll, *.pyd
4343

4444
[options.packages.find]
4545
exclude =

0 commit comments

Comments
 (0)