For-a-few-DPPs-more/spatstat-interface

package fails when installing with poetry on macos

Opened this issue · 1 comments

Hi,

There seems to be some dependency issues, when installing the package with poetry, which I'm guessing is related to recent changes to numpy. Calling from spatstat_interface.interface import SpatstatInterface I get:

% python
Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 10:07:17) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from spatstat_interface.interface import SpatstatInterface
During startup - Warning messages:
1: Setting LC_COLLATE failed, using "C" 
2: Setting LC_TIME failed, using "C" 
3: Setting LC_MESSAGES failed, using "C" 
4: Setting LC_MONETARY failed, using "C" 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/spatstat_interface/interface.py", line 3, in <module>
    from spatstat_interface.utils import install_r_package
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/spatstat_interface/utils.py", line 3, in <module>
    from rpy2.robjects import pandas2ri
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/rpy2/robjects/pandas2ri.py", line 16, in <module>
    import pandas  # type: ignore
    ^^^^^^^^^^^^^
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev  # pyright: ignore # noqa:F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/pandas/compat/__init__.py", line 18, in <module>
    from pandas.compat.numpy import (
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
    from pandas.util.version import Version
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/pandas/util/__init__.py", line 2, in <module>
    from pandas.util._decorators import (  # noqa:F401
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/pandas/util/_decorators.py", line 14, in <module>
    from pandas._libs.properties import cache_readonly
  File "/Users/jrh630/anaconda3/envs/spatstat_interface/lib/python3.12/site-packages/pandas/_libs/__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
  File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I installed the package by:

brew install pipx
pipx install poetry
poetry init

where I created a dummy project:

Generated file

[tool.poetry]
name = "spatstat-test"
version = "0.1.0"
description = ""
authors = ["Jon Sporring <sporring@di.ku.dk>"]
readme = "README.md"

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

and then I installed spatstat-interface

poetry add spatstat-interface

which fetched the following:

Using version ^1.0.1 for spatstat-interface

Updating dependencies
Resolving dependencies... (1.6s)

Package operations: 12 installs, 0 updates, 0 removals

  - Installing markupsafe (2.1.5)
  - Installing pycparser (2.22)
  - Installing six (1.16.0)
  - Installing cffi (1.17.0)
  - Installing jinja2 (3.1.4)
  - Installing numpy (2.0.1)
  - Installing python-dateutil (2.9.0.post0)
  - Installing pytz (2024.1)
  - Installing tzlocal (5.2)
  - Installing pandas (1.5.3)
  - Installing rpy2 (3.5.16)
  - Installing spatstat-interface (1.0.1)

Best, Jon

It seems that upgrading pandas to the latest version fixes the problem in spite of the apparent dependency breakage:

pip install --upgrade pandas 
...
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spatstat-interface 1.0.1 requires pandas<2.0.0,>=1.2.4, but you have pandas 2.2.2 which is incompatible.
Successfully installed pandas-2.2.2 tzdata-2024.1

Now, in python, everything seems fine:

>>> from spatstat_interface.interface import SpatstatInterface
During startup - Warning messages:
1: Setting LC_COLLATE failed, using "C" 
2: Setting LC_TIME failed, using "C" 
3: Setting LC_MESSAGES failed, using "C" 
4: Setting LC_MONETARY failed, using "C" 
>>>