Specifying version of GDAL dependency with Poetry

102 views Asked by At

My Python project uses Poetry for dependency management. It requires the GDAL package, which (on Linux) requires that libgdal-dev is installed on the system. Moreover, the version of the Python package should match that of libgdal-dev.

How do I handle this situation with Poetry?

I could fix the version of the Python package in pyproject.toml and require users to install the same version of libgdal-dev. However, the available versions of libgdal-dev are very much constrained, depending on the system. For example, only one GDAL version per Ubuntu version is available on the standard Ubuntu PPA and it varies depending on the Ubuntu version. Moreover, my project also needs to work on a Linux cluster which has a bunch of libgdal-dev versions installed, but no easy way of installing a different one.

Ideally, the GDAL version in pyproject.toml would be dynamic, and obtained e.g. from an environment variable but that doesn't seem to be supported.

Edit

I just found this post, of which mine is essentially a duplicate. However, the accepted answer basically does the reverse of what the OP (and I) asked for: setting the version of libgdal-dev to that specified in pyproject.toml. This may be sufficient for some scenarios, but not in mine, as question hopefully illustrates.

0

There are 0 answers