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

Building wheels for Windows #48

Closed
jorisvandenbossche opened this issue Feb 25, 2022 · 11 comments
Closed

Building wheels for Windows #48

jorisvandenbossche opened this issue Feb 25, 2022 · 11 comments

Comments

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Feb 25, 2022

I have been looking a bit into the option to use vcpkg to get the GDAL binaries necessary for wheel building, and then combined with cibuildwheel for the wheel building automation.

Vcpkg is a "cross-platform C/C++ package manager" (using installation from source not providing binaries), and provides a recipe or "port" for GDAL: https://vcpkg.info/port/gdal (which allows you to install GDAL from source on windows with a basic vcpkg install gdal).
In Apache Arrow, we are also using it for building the wheels (and pyarrow also has a notoriously complex wheel, similar to requiring GDAL), and so in principle we could also use it for the other platforms (linux, mac) as well, and not just for windows (I just started with windows, since for the other platforms we could in principle start with mimicking fiona's wheel building infrastructure).

I suppose there are also other options for building wheels on Windows, by getting the binaries from elsewhere (eg https://www.gisinternals.com/, https://github.com/gisinternals/buildsystem/tree/refactor). But I also don't have any idea how easy that would be compared to vcpkg (which has the potential to give us a somewhat consistent build setup for all platforms).


Yesterday, I finally had some first success while trying out this workflow on a local windows machine. See my branch at https://github.com/jorisvandenbossche/pyogrio/tree/cibuildwheel-windows.

I managed to create a wheel, that seems to work, with the following steps:

With this, I created a single wheel for Python 3.9:
pyogrio-0.3.0+18.gefdca6d.dirty-cp39-cp39-win_amd64.zip
I needed to rename it to allow it to upload to this issue, so for testing it, you can download it, rename it and install it with pip:

rename "pyogrio-0.3.0+18.gefdca6d.dirty-cp39-cp39-win_amd64.zip" "pyogrio-0.3.0+18.gefdca6d.dirty-cp39-cp39-win_amd64.whl"
pip install pyogrio-0.3.0+18.gefdca6d.dirty-cp39-cp39-win_amd64.whl

From a quick test (installing it in a clean env), this seems to work, I was able to read a zipped shapefile! (a cautious 🎉)

For someone with a Windows machine, please test this wheel


Next steps

What I did locally, as described above, should in principle all be doable in CI using github actions as well. So the next step is trying to do that:

Help here would be very much appreciated!

@martinfleis
Copy link
Member

Yay! It works flawlessly on my machine in a fresh conda env with geopandas-base (no other GDAL installed). Thanks a lot for looking into this! Having Windows wheels for IO would significantly ease the installation pain for many users.

@martinfleis
Copy link
Member

A potential challenge here is that building it with vcpkg install gdal[core] takes quite a long time (even with the [core]), with the risk of timing out

How long does it take? The GHA docs say that

Each job in a workflow can run for up to 6 hours of execution time

It should not take longer that that. I think that we need to manually set higher timeout in the workflow but I guess we'll fit in 6 hours.

@jorisvandenbossche
Copy link
Member Author

Yeah, 6 hours should be enough :) (on my machine, it took more than an hour)

@jorisvandenbossche
Copy link
Member Author

One thing I realized is that the current wheel is missing is the "gdal data" and "proj data" (the Fiona wheel contains this in the fiona package, in addition to Fiona.libs folder with binaries).
I find it strange that this doesn't give an error, though, when reading a file (since that already accesses a CRS).

@brendan-ward
Copy link
Member

Is it possible that we don't actually need gdal data and proj data? We are only getting or setting CRS info, but not reprojecting anything. I don't know if the gdal / proj data are used to encode / decode CRS from the underyling driver to CRS WKT.

@jorisvandenbossche
Copy link
Member Author

I don't know if the gdal / proj data are used to encode / decode CRS from the underyling driver to CRS WKT.

I was assuming that it would need that, at least for eg OSRExportToWkt (since not every file format stores it as WKT, and this function interacts with PROJ). But we also only use OSRExportToWkt if there is no authority/code combo. So maybe the quick tests we did didn't run into that.

@jorisvandenbossche
Copy link
Member Author

Doing a first attempt to put this in a github actions workflow -> #49 (and it only took less than an hour to build gdal core! and it gets cached after the first time).
On my fork, I already got up to running the tests, and I see several ERROR 1: PROJ: proj_identify: Cannot find proj.db logs. So I think this is an indication that we will need to add some "data path" handling to pyogrio for wheels .. (in the line of what fiona is doing at https://github.com/Toblerity/Fiona/blob/9c8fe736d4381526905c6976c399a33d10e3ecbf/fiona/_env.pyx#L269-L449)

@jorisvandenbossche
Copy link
Member Author

If people want to test the latest version of the wheels, you can download the archive with wheels from https://github.com/geopandas/pyogrio/suites/5620607087/artifacts/183019252.
Unpack that, and then pip install path/to/unpacked/archive/pyogrio-....whl using the exact wheel name matching your python version.

@brendan-ward
Copy link
Member

This has been completed for 0.4.0

@RitaAguiarAdsk
Copy link

@jorisvandenbossche The link to the archive with wheels is not working. Could you tell me the right link? I'm looking for the gdal 3.5.3 wheel for windows. Thank you.

If people want to test the latest version of the wheels, you can download the archive with wheels from https://github.com/geopandas/pyogrio/suites/5620607087/artifacts/183019252. Unpack that, and then pip install path/to/unpacked/archive/pyogrio-....whl using the exact wheel name matching your python version.

@brendan-ward
Copy link
Member

@RitaAguiarAdsk We haven't yet released wheels with 3.5.x to pypi; sorry about that.

I just triggered a fresh build of the release workflow, which regenerated Windows wheels here: https://github.com/geopandas/pyogrio/actions/runs/3576011156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants