Search code examples
python-poetry

Xarray-Spatial and Poetry compatibility


I'm trying to install xarray-spatial via poetry on Ubuntu 22.04, below the simple .toml with which I've tried to install the library:

[tool.poetry]
name = "xarray-spatial-test"
version = "0.1.0"
description = ""
authors = []
readme = "README.md"
packages = [{include = "xarray_spatial"}]

[tool.poetry.dependencies]
python = "^3.10"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

When I use poetry add xarray-spatial I see the error below:

Using version ^0.3.5 for xarray-spatial

Updating dependencies
Resolving dependencies... (0.0s)

  AssertionError

  

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/mixology/incompatibility.py:113 in __str__
      109│         )
      110│ 
      111│     def __str__(self) -> str:
      112│         if isinstance(self._cause, DependencyCause):
    → 113│             assert len(self._terms) == 2
      114│ 
      115│             depender = self._terms[0]
      116│             dependee = self._terms[1]
      117│             assert depender.is_positive()

This is strange because I've already used it withouth problems but on Ubuntu 20.04. This is also strange because I can install whitouth problems using pip3 install xarray-spatial in a test environment(python3 -m venv test_env) and if i use xrspatial examples I can downloads the examples.

Is there a compatibility problem between Poetry and xarray-spatial?

NB: I can't add the tag xarray-spatial, if someone can please add it.


Solution

  • The error above is that xarray-spatial should be added under the [tool.poetry.dependencies] section of pyproject.toml rather than in the packages section.

    Removing {include = "xarray_spatial"} from the above file and running poetry add xarray-spatial from your project will update pyproject.toml with the correct version of the package for your project.