pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

Upgrading to Shapely 2.0

Open sjordan29 opened this issue 2 years ago • 2 comments

Opening this issue to discuss upgrading pygeoapi to Shapely>2.0. Other processing plugins that we're working with are using Shapely 2.0; the upgrade to Shapely 2.0 has made a big difference in performance for those plugins, but results in compatibility issues with pygeoapi (Shapely<2.0).

We noticed that a PR from Dec 2022 (#1072) marks a decision to stay with Shapely 1.x for a while due to the increased install footprint with numpy as a hard dependency. I also understand from @dblodgett-usgs and @rmcd-mscb that Debian is important and pygeoapi likely uses stable packages from Debian, which could be another blocker for the upgrade. We're tracking progress of Shapely 2.0 on Debian; 2.0.2 is currently tagged in testing, so we're hopeful that there may be a stable version that could be leveraged for pygeoapi soon (link).

Initial testing of pygeoapi shows pretty minimal impact of switching to Shapely 2.0. There were several deprecation warnings that popped up, but those could be quickly resolved (e.g., in this branch on our fork of pygeoapi) and appear to pass all pytests.

sjordan29 avatar Oct 31 '23 15:10 sjordan29

As per RFC4, this Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.

github-actions[bot] avatar Mar 10 '24 21:03 github-actions[bot]

Thank you for the feedback. Moving to Shapely 2.0 should be discussed during a project meeting.

kalxas avatar Mar 14 '24 09:03 kalxas

Could this be upped in importance? When running the basic installation as a noob locally, I had to downgrade my Python version to 3.11, from 3.12, because of https://stackoverflow.com/questions/77364550/attributeerror-module-pkgutil-has-no-attribute-impimporter-did-you-mean, which was directly caused by Shapely having a non-updated version. This isn't the worst thing to have to do, but also it seems like an annoying user experience.

If it helps, feel free to use my simple upgrade PR at https://github.com/geopython/pygeoapi/pull/1614.

KilimAnnejaro avatar Apr 07 '24 23:04 KilimAnnejaro

Given Shapely 2 is now default in Ubuntu noble, and rasterio is a core requirement (which requires Numpy), and that our use of Shapely works for both Shapely 1.x and 2.x, I think it's a good time to move unpin Shapely in requirements.txt per #1614.

tomkralidis avatar Apr 15 '24 15:04 tomkralidis

Was this fixed? I am finding that a pip install with python 3.12.4 does not work. (Using pipx here to isolate global dependencies but same issue applies when running via global pip)

> pipx install pygeoapi
Fatal error from pip prevented installation. Full pip output in file:
    /Users/cloftus/.local/pipx/logs/cmd_2024-07-03_15.00.54_pip_errors.log

pip seemed to fail to build package:
    shapely<2.0

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

Error installing pygeoapi.

C-Loftus avatar Jul 03 '24 19:07 C-Loftus

Looks like you are pulling 0.16.1 from PyPI.

We are releasing 0.17.0 shortly which should fix this issue. In the meantime, you can try installing from master branch as a workaround.

tomkralidis avatar Jul 04 '24 06:07 tomkralidis