Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build wheels using vcpkg for Linux/MacOS #55

Merged
merged 69 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b1061ea
First attempt at vcpkg for Linux / MacOS on CI
brendan-ward Mar 11, 2022
93b53d6
Try again with caching and correct paths for GDAL
brendan-ward Mar 11, 2022
73bf65f
Try again on macos, try different paths for linux
brendan-ward Mar 11, 2022
30d9d8a
fix expression
brendan-ward Mar 11, 2022
9df3287
Try to fix expression again
brendan-ward Mar 11, 2022
d265d01
Fix more syntax errors
brendan-ward Mar 11, 2022
dfa25cc
Try to get GDAL cached for future builds
brendan-ward Mar 11, 2022
9451f6f
Use correct paths for linux, try to get logs from failed macos GDAL b…
brendan-ward Mar 11, 2022
016a7b0
Build Linux wheels and try to patch MacOS deps
brendan-ward Mar 11, 2022
e6b308f
Try to figure out vcpkg config
brendan-ward Mar 12, 2022
8e52406
Keep probing for vcpkg install location
brendan-ward Mar 12, 2022
829e77e
Fix incorrect comments
brendan-ward Mar 12, 2022
625dccb
Keep trying to find vcpkg install location
brendan-ward Mar 12, 2022
9682df4
Try again to find cache location for vcpkg
brendan-ward Mar 12, 2022
afac704
Try test of caching again
brendan-ward Mar 12, 2022
942ee9c
Fix dumb mistake
brendan-ward Mar 12, 2022
a468198
Try GDAL build again with correct cache paths and lib paths
brendan-ward Mar 12, 2022
d420414
Try to cache GDAl build for MacOS
brendan-ward Mar 12, 2022
b33f2d9
Run linux GDAL build to cache for next time
brendan-ward Mar 12, 2022
bde5cab
Try again with /host to use GDAL on docker host for Linux
brendan-ward Mar 12, 2022
ee5fe8c
re-enable wheel building for mac
jorisvandenbossche Mar 12, 2022
d9375a5
fix pyproject.toml macos table + update incluce/library paths
jorisvandenbossche Mar 12, 2022
ab37f1f
update wheel installation
jorisvandenbossche Mar 12, 2022
1c4577b
temp disable mac tests
jorisvandenbossche Mar 12, 2022
67f9997
try setting LD_LIBRARY_PATH
jorisvandenbossche Mar 12, 2022
105b50b
fix data path + try running delocate manually to debug
jorisvandenbossche Mar 12, 2022
3929824
verbose build
jorisvandenbossche Mar 12, 2022
ad9aeaf
try mac repair tip
jorisvandenbossche Mar 12, 2022
1de7027
fix data paths
jorisvandenbossche Mar 12, 2022
6b6bc28
try MACOSX_DEPLOYMENT_TARGET
jorisvandenbossche Mar 12, 2022
8e900ce
try building custom docker image
jorisvandenbossche Mar 15, 2022
5ab8e63
specify cache dir via docker build-push action
jorisvandenbossche Mar 15, 2022
5905e97
reenable cibuildwheel for linux + point to customly build docker
jorisvandenbossche Mar 15, 2022
d12b5b7
debug: list images
jorisvandenbossche Mar 15, 2022
677ed69
docker-build-push to load built image into docker images
jorisvandenbossche Mar 15, 2022
6e74c45
skip musllinux
jorisvandenbossche Mar 15, 2022
d882157
Try with custom triplets for MacOS
brendan-ward Mar 15, 2022
4222e62
update env variables for new triplet
jorisvandenbossche Mar 15, 2022
42578da
disable tests to have succesfull build (and have artifacts)
jorisvandenbossche Mar 15, 2022
f1b1ff9
Bump cache key for macos
brendan-ward Mar 15, 2022
faadbc5
print proj data files
jorisvandenbossche Mar 15, 2022
4c9dcfe
another attempt to print the proj data paths
jorisvandenbossche Mar 16, 2022
66b7791
another attempt to print the proj data paths
jorisvandenbossche Mar 16, 2022
bd296ee
another attempt to print the proj data paths
jorisvandenbossche Mar 16, 2022
544fb5f
check proj4 data path
jorisvandenbossche Mar 16, 2022
8873a72
use correct data path for proj
jorisvandenbossche Mar 16, 2022
28f94b9
re-enable tests
jorisvandenbossche Mar 16, 2022
29b1ce7
Try building for MacOS 10.15
brendan-ward Mar 16, 2022
90dd348
Make sure that build cache is unique to MacOS version
brendan-ward Mar 16, 2022
4ab4cc2
Add logging to pytest to try to debug test failures on MacOS
brendan-ward Mar 16, 2022
bfe011f
Try adding pyproject config for pytest
brendan-ward Mar 16, 2022
e292009
--pyargs pyogrio.tests
jorisvandenbossche Mar 16, 2022
e0c1eb9
temp set curl env variable for certificate
jorisvandenbossche Mar 16, 2022
f922f97
try github cache feature for docker
jorisvandenbossche Mar 16, 2022
dc45654
test cache
jorisvandenbossche Mar 16, 2022
ea63984
Merge branch 'main' into vcpkg_linux_macos
brendan-ward Mar 17, 2022
ce24eef
Update pytest call for Windows wheels
brendan-ward Mar 17, 2022
1300be4
Remove superseded Linux build, skip MacOS test against 3.10 wheel
brendan-ward Mar 17, 2022
b133504
Only build MacOS 10.15 wheels
brendan-ward Mar 17, 2022
c78cd03
Fix windows test job name
brendan-ward Mar 17, 2022
21d14d6
Put back linux build
brendan-ward Mar 18, 2022
813707f
small cleanup
jorisvandenbossche Mar 18, 2022
5da1f7c
make testing sectin consistent across files
jorisvandenbossche Mar 18, 2022
cb2e7c9
clean-up linux file
jorisvandenbossche Mar 18, 2022
06e5e2f
load docker image
jorisvandenbossche Mar 18, 2022
e6d24eb
fixup directory for linux tests
jorisvandenbossche Mar 18, 2022
f74601a
restore docker-build-push action for cache
jorisvandenbossche Mar 18, 2022
37c57fd
small clean-up pyproject.toml file
jorisvandenbossche Mar 18, 2022
234c8f6
cannot specify both general and platform specific environment variables
jorisvandenbossche Mar 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build_wheel_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Build wheels for Windows
on:
push:
branches:
- main # just build the sdist & wheel, skip release
- main # just build the sdist & wheel, skip release
tags:
- "*"
pull_request: # also build on PRs touching files that affect wheels
pull_request: # also build on PRs touching files that affect wheels
paths:
- ".github/workflows/build_wheel.yml"
- "MANIFEST.in"
Expand Down Expand Up @@ -46,13 +46,13 @@ jobs:
path: ./wheelhouse/*.whl

test_wheels:
name: windows py${{ matrix.python-version }} tests
name: windows python ${{ matrix.python-version }} tests
runs-on: windows-latest
needs: build_wheels
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ["3.8", "3.9", "3.10"]

steps:
- name: Checkout
Expand All @@ -64,8 +64,8 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'ci/requirements-wheel-test.txt'
cache: "pip"
cache-dependency-path: "ci/requirements-wheel-test.txt"

- name: Download wheels from artifacts
uses: actions/download-artifact@v2
Expand All @@ -89,4 +89,4 @@ jobs:
shell: bash
run: |
cd ..
python -m pytest --pyargs pyogrio
python -m pytest --pyargs pyogrio.tests -v
114 changes: 114 additions & 0 deletions .github/workflows/build_wheels_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build Linux wheels

on:
push:
branches:
- main # just build the sdist & wheel, skip release
tags:
- "*"
pull_request: # also build on PRs touching this file
paths:
- ".github/workflows/build_wheels_linux.yml"
- "ci/*"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
workflow_dispatch:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }} ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04"]
platform: ["x86_64"]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true

# - name: Build Docker image with vcpkg and gdal
# run: |
# docker build -t manylinux-vcpkg-gdal -f ci/manylinux2014_x86_64-vcpkg-gdal.Dockerfile .

- name: Build Docker image with vcpkg and gdal
# using build-push-action (without push) to make use of cache arguments
uses: docker/build-push-action@v2
with:
context: .
file: ci/manylinux2014_x86_64-vcpkg-gdal.Dockerfile
tags: manylinux-vcpkg-gdal:latest
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- run: |
docker images

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

test-wheel:
name: Test wheels on ${{ matrix.os }} ${{ matrix.platform }}
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04"]
platform: ["x86_64"]
python-version: ["3.8", "3.9", "3.10"]

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: false

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Download wheels from artifacts
uses: actions/download-artifact@v2
with:
path: wheelhouse

- name: Set version string
shell: bash
run: echo "py_version_str=cp$(echo ${{ matrix.python-version }} | tr -d -c 0-9)" >> $GITHUB_ENV

- name: Install package from wheel
shell: bash
run: |
ls -R wheelhouse
python -m pip install --upgrade pip
python -m pip install wheelhouse/artifact/pyogrio-*${{ env.py_version_str }}*.whl

- name: Run tests
# TODO temporary set env variable for curl certificate
env:
CURL_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
run: |
python -m pip install pytest pandas pyproj shapely packaging
python -m pip install --no-deps geopandas
python -m pip list
pwd
ls
cd ..
python -m pytest --pyargs pyogrio.tests
114 changes: 114 additions & 0 deletions .github/workflows/build_wheels_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build MacOS wheels

on:
push:
branches:
- main # just build the sdist & wheel, skip release
tags:
- "*"
pull_request: # also build on PRs touching this file
paths:
- ".github/workflows/build_wheels_macos.yml"
- "ci/*"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
workflow_dispatch:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }} ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["macos-10.15"]
platform: ["x86_64"]

env:
MACOSX_DEPLOYMENT_TARGET: "10.15"

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Cache vcpkg
uses: actions/cache@v1
id: vcpkgcache
with:
path: "/Users/runner/.cache/vcpkg/archives"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Windows PR, I am caching the actual "/installed" directory directly (https://github.com/geopandas/pyogrio/pull/49/files#diff-6c1677623c2a63cdf28017fb8aa9b0395ecf72745a91b9ccd9228dbac36b4475R34). Do you know if there is a big difference? (both seem to work, and I think I have seen both in practice in other projects)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back to /Users/runner/.cache/vcpkg/archives only because it was getting emitted by the logs on GH, and I couldn't figure out the correct install location.

For me, I had git cloned vcpkg to a local folder, so the installed/x64-osx-dynamic/ path ended up being under that.

From earlier testing of just building GDAL, it seems like it cached things fine using /Users/runner/.cache/vcpkg/archives and may be preferable to use that if that is based on a hash relating to the version of GDAL + deps that are actually installed, if we want those to rebuild on updates from vcpkg (which is debatable).

key: ${{ matrix.os }}-${{ matrix.platform }}-vcpkg-gdal3.4.1-dynamic

# MacOS build requires aclocal, which is part of automake, but appears
# to be missing in default image
- name: Reinstall automake
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew reinstall automake
echo $(which aclocal)

- name: Install GDAL
run: |
vcpkg install gdal[core]:x64-osx-dynamic --overlay-triplets=./ci/custom-triplets

- name: Upload build logs
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
path: /usr/local/share/vcpkg/buildtrees/gdal/*.log

- name: Build wheels
uses: pypa/[email protected]
env:
PYOGRIO_PACKAGE_DATA: 1

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

test-wheel:
name: Test wheels on ${{ matrix.os }} ${{ matrix.platform }}
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "macos-10.15"]
platform: ["x86_64"]
python-version: ["3.8", "3.9"]

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: false

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Download wheels from artifacts
uses: actions/download-artifact@v2
with:
path: wheelhouse

- name: Set version string
shell: bash
run: echo "py_version_str=cp$(echo ${{ matrix.python-version }} | tr -d -c 0-9)" >> $GITHUB_ENV

- name: Install package from wheel
shell: bash
run: |
ls -R wheelhouse
python -m pip install --upgrade pip
python -m pip install wheelhouse/artifact/pyogrio-*${{ env.py_version_str }}*.whl

- name: Run tests
run: |
python -m pip install pytest pandas pyproj shapely packaging
python -m pip install --no-deps geopandas
python -m pip list
cd ..
python -m pytest --pyargs pyogrio.tests -v
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ include versioneer.py
include pyogrio/_version.py
include pyogrio/*.pyx pyogrio/*.pxd
exclude pyogrio/*.c
include LICENSE
include pyproject.toml
exclude MANIFEST.in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to change this back (I think it is a left-over from some experimentation to get the tests working?), as my understanding is that this should not influence wheels but only sdist. This might still be a valid change for the sdist (didn't check that here), but then let's do that in a separate PR focused on sdist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine; I added that while trying to get the pytest tests working, based on adapting what we have in pygeos. Certainly fine to deal with it in later PR.

recursive-include pyogrio/tests/fixtures *
5 changes: 5 additions & 0 deletions ci/custom-triplets/x64-linux-dynamic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
set(VCPKG_BUILD_TYPE release)
5 changes: 5 additions & 0 deletions ci/custom-triplets/x64-osx-dynamic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_BUILD_TYPE release)
17 changes: 17 additions & 0 deletions ci/manylinux2014_x86_64-vcpkg-gdal.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM quay.io/pypa/manylinux2014_x86_64

RUN yum install -y curl unzip zip tar python3

RUN git clone https://github.com/Microsoft/vcpkg.git /opt/vcpkg

ENV VCPKG_INSTALLATION_ROOT="/opt/vcpkg"
ENV PATH="${PATH}:/opt/vcpkg"

RUN bootstrap-vcpkg.sh && \
vcpkg integrate install && \
vcpkg integrate bash

COPY ci/custom-triplets/x64-linux-dynamic.cmake opt/vcpkg/custom-triplets/x64-linux-dynamic.cmake

ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/vcpkg/installed/x64-linux-dynamic/lib"
RUN vcpkg install gdal[core]:x64-linux-dynamic --overlay-triplets=opt/vcpkg/custom-triplets
4 changes: 2 additions & 2 deletions pyogrio/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def pytest_report_header(config):
)


@pytest.fixture
@pytest.fixture(scope="session")
def data_dir():
return _data_dir

Expand All @@ -28,7 +28,7 @@ def naturalearth_lowres():
return _data_dir / Path("naturalearth_lowres/naturalearth_lowres.shp")


@pytest.fixture
@pytest.fixture(scope="function")
def naturalearth_lowres_vsi(tmp_path, naturalearth_lowres):
"""Wrap naturalearth_lowres as a zip file for vsi tests"""

Expand Down
33 changes: 32 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,35 @@ requires = [
]

[tool.cibuildwheel]
skip = ["cp36-*", "cp37-*", "pp*"]
skip = ["cp36-*", "cp37-*", "pp*", "*musllinux*"]
archs = ["auto64"]
manylinux-x86_64-image = "manylinux-vcpkg-gdal:latest"
build-verbosity = 3

[tool.cibuildwheel.linux]
# explicitly mention 2_27 for now because it fails for manylinux2014 (2_17)
repair-wheel-command = "auditwheel repair --plat manylinux_2_27_x86_64 -w {dest_dir} {wheel}"

[tool.cibuildwheel.linux.environment]
VCPKG_INSTALL = "$VCPKG_INSTALLATION_ROOT/installed/x64-linux-dynamic"
GDAL_INCLUDE_PATH = "$VCPKG_INSTALL/include"
GDAL_LIBRARY_PATH = "$VCPKG_INSTALL/lib"
PYOGRIO_PACKAGE_DATA = 1
GDAL_DATA = "$VCPKG_INSTALL/share/gdal/gdal"
PROJ_LIB = "$VCPKG_INSTALL/share/proj/data"

[tool.cibuildwheel.macos]
repair-wheel-command = [
"DYLD_LIBRARY_PATH=$GDAL_LIBRARY_PATH delocate-listdeps {wheel}",
"DYLD_LIBRARY_PATH=$GDAL_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
]

[tool.cibuildwheel.macos.environment]
VCPKG_INSTALL = "$VCPKG_INSTALLATION_ROOT/installed/x64-osx-dynamic"
GDAL_INCLUDE_PATH = "$VCPKG_INSTALL/include"
GDAL_LIBRARY_PATH = "$VCPKG_INSTALL/lib"
GDAL_DATA = "$VCPKG_INSTALL/share/gdal/gdal"
PROJ_LIB = "$VCPKG_INSTALL/share/proj4"

[tool.cibuildwheel.windows]
archs = ["auto64"]
Expand All @@ -23,3 +51,6 @@ GDAL_LIBRARY_PATH = "$VCPKG_INSTALL/lib"
PYOGRIO_PACKAGE_DATA = 1
GDAL_DATA = "$VCPKG_INSTALL/share/gdal"
PROJ_LIB = "$VCPKG_INSTALL/share/proj4"

[tool.pytest.ini_options]
testpaths = ["pyogrio/tests"]
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def get_gdal_paths():
if not gdal_version >= MIN_GDAL_VERSION:
sys.exit("GDAL must be >= 2.4.x")

include_dirs = [
entry[2:] for entry in config["cflags"].split(" ")
]
include_dirs = [entry[2:] for entry in config["cflags"].split(" ")]
library_dirs = []
libraries = []
extra_link_args = []
Expand All @@ -92,7 +90,7 @@ def get_gdal_paths():
libraries.append(entry[2:])
else:
extra_link_args.append(entry)

return {
"include_dirs": include_dirs,
"library_dirs": library_dirs,
Expand Down