igraph / python-igraph

Python interface for igraph
GNU General Public License v2.0
1.31k stars 249 forks source link

Python 3.13 compatibility #795

Closed xylar closed 2 months ago

xylar commented 2 months ago

Based on the attempt to build with python 3.13 on conda-forge, it seems like some work may be needed before python-igraph is compatible. We're seeing failures in a lot of tests with messages like the following:

======================================================================
ERROR: testAdjacency (tests.test_basic.BasicTests.testAdjacency)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/conda/feedstock_root/build_artifacts/python-igraph_1725317163812/test_tmp/tests/test_basic.py", line 350, in testAdjacency
    self.assertTrue(g.get_adjlist(IN) == [[2], [0], [1], [2]])
                    ~~~~~~~~~~~~~^^^^
  File "/home/conda/feedstock_root/build_artifacts/python-igraph_1725317163812/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.13/site-packages/igraph/adjacency.py", line 135, in _get_adjlist
    return [self.neighbors(idx, mode) for idx in range(self.vcount())]
            ~~~~~~~~~~~~~~^^^^^^^^^^^
SystemError: <method 'neighbors' of 'igraph._igraph.GraphBase' objects> returned NULL without setting an exception

======================================================================
ERROR: testEdgeIncidence (tests.test_basic.BasicTests.testEdgeIncidence)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/conda/feedstock_root/build_artifacts/python-igraph_1725317163812/test_tmp/tests/test_basic.py", line 356, in testEdgeIncidence
    self.assertTrue(g.incident(2, IN) == [1])
                    ~~~~~~~~~~^^^^^^^
SystemError: <method 'incident' of 'igraph._igraph.GraphBase' objects> returned NULL without setting an exception

See https://github.com/conda-forge/python-igraph-feedstock/pull/91

Also likely relevant:

ntamas commented 2 months ago

I've noticed this in CI but haven't had time to deal with it yet, especially because it seems to be related to Linux only; I can't reproduce it with macOS (M1) and Python 3.13.0rc1. I'll try on Linux soon.

ntamas commented 2 months ago

https://github.com/igraph/python-igraph/commit/8abba79c19675f39e4648e9b03bcd000b965ee3c might be a fix for this issue; let's see how it fares in CI.

xylar commented 2 months ago

@ntamas, thanks for responding so quickly! Fingers crossed.

ntamas commented 2 months ago

CI passed. I'm aiming for a new patch release soon(ish), in the next few days. You can apply 8abba79 manually if you can't wait for the next patch release.

xylar commented 2 months ago

@ntamas, Thanks for adding this support so quickly! I'll take your suggestion and patch for now.