Skip to content

Commit

Permalink
Use a manylinux wheel for linux builds
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 9, 2023
1 parent ad7e684 commit 841cfbf
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 21 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
uses: supercharge/[email protected]
with:
mongodb-version: 6.0
- name: Install libbson
run: |
LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh
- name: Install Python dependencies
run: |
python -m pip install -U pip
Expand All @@ -60,14 +57,15 @@ jobs:
# the current target that this PR will be merged into is HEAD^1.
git update-ref refs/bm/merge-target $(git log -n 1 --pretty=format:"%H" main --)
git checkout --force refs/bm/pr --
# Install the library
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e ".[test]"
# Build and install the manylinux wheel
bash ./build-manylinux-wheel.sh
pip install dist/*.whl
run_asv
git checkout --force refs/bm/merge-target --
# Install the library
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e ".[test]"
# Build and install the manylinux wheel
bash ./build-manylinux-wheel.sh
pip install dist/*.whl
run_asv
- name: Compare benchmarks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
Expand Down
36 changes: 27 additions & 9 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ jobs:
extra_args: --all-files --hook-stage=manual

build:
# supercharge/mongodb-github-action requires containers so we don't test other platforms
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-20.04", "macos-latest", "windows-latest"]
os: ["macos-latest", "windows-latest"]
python-version: [3.8, 3.9, "3.10", "3.11"]
fail-fast: false
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
Expand All @@ -49,12 +48,6 @@ jobs:
run: |
echo "LIBBSON_INSTALL_DIR=$PWD/libbson" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$PWD/libbson/lib" >> $GITHUB_ENV
- name: Start MongoDB on Linux
if: ${{ startsWith(runner.os, 'Linux') }}
uses: supercharge/[email protected]
with:
mongodb-version: 4.4
mongodb-replica-set: test-rs
- name: Start MongoDB on MacOS
if: ${{ startsWith(runner.os, 'macOS') }}
run: |
Expand Down Expand Up @@ -89,13 +82,38 @@ jobs:
- name: Run the tests
run: |
python -m pytest -v
build-linux:
runs-on: ubuntu-latest
name: CPython Ubuntu
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: 'bindings/python/pyproject.toml'
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.4
mongodb-replica-set: test-rs
- name: Build and install package and test deps
run: |
bash build-manylinux-wheel.sh
pip install dist/*.whl
pip install pytz pytest
- name: Run the tests
run: |
python -m pytest -v
- name: Check the manifest
run: |
pip install check-manifest
check-manifest -v
docs:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Cache conda
Expand Down
11 changes: 11 additions & 0 deletions bindings/python/build-manylinux-wheel-internal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -ex
cd /src
LIBBSON_INSTALL_DIR=$(pwd)/libbson
rm -rf $LIBBSON_INSTALL_DIR
./build-libbson.sh
rm -rf build dist
PYTHON=/opt/python/cp311-cp311/bin/python
$PYTHON -m pip install build
$PYTHON -m build --wheel .
rm -rf $LIBBSON_INSTALL_DIR
rm -rf build
8 changes: 8 additions & 0 deletions bindings/python/build-manylinux-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -ex

set -o xtrace
set -o errexit

image="quay.io/pypa/manylinux2014_x86_64"
docker pull $image
docker run --rm -v "`pwd`:/src" $image /src/build-manylinux-wheel-internal.sh
8 changes: 5 additions & 3 deletions bindings/python/docs/source/developer/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Command Line Tools. Additionally, you need CMake and pkg-config::
$ brew install cmake
$ brew install pkg-config

On Linux, you require gcc 4.8, CMake and pkg-config.
On Linux, you will need docker, to run the "build-manylinux-wheel.sh" script.

Windows is not yet supported.
On Windows, you will need Visual Studio 2017 or later, with the Python Development
workload installed.

Environment Setup
-----------------
Expand All @@ -37,7 +38,6 @@ PyMongoArrow uses `libbson <http://mongoc.org/libbson/current/index.html>`_.
Detailed instructions for building/installing ``libbson`` can be found
`here <http://mongoc.org/libmongoc/1.21.0/installing.html#installing-the-mongodb-c-driver-libmongoc-and-bson-library-libbson>`_.


You can either use a system-provided version of ``libbson`` that is properly
configured for use with ``pkg-config``, or use the provided ``build-libbson.sh`` script to build it::

Expand Down Expand Up @@ -65,6 +65,8 @@ If you built libbson using the `build-libbson` script then use the same `LIBBSON

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

Note: we do not support editable installs on Linux, the "build-manylinux-wheel.sh" script must be used
to create the wheel.

Test
----
Expand Down

0 comments on commit 841cfbf

Please sign in to comment.