antocuni / capnpy

Other
45 stars 26 forks source link

WIP: Python 3.11 support #58

Closed antocuni closed 1 year ago

antocuni commented 3 years ago

I opened this PR to check whether capnpy is compatible with python3.11, but it turns out that there are at least two problems:

  1. tox seems to crash; github action output:

    Traceback (most recent call last):
    File "/opt/hostedtoolcache/Python/3.11.0-alpha.1/x64/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 145, in __makeattr
    modpath, attrname = self.__map__[name]
                        ~~~~~~~~~~~~^^^^^^
    KeyError: '__spec__'
  2. I tried to compile it manually on my machine and stumbled upon this Cython issue: https://github.com/cython/cython/issues/4365

kvelicka commented 1 year ago

Hi.

For sake of documentation: there seems to be another issue, seemingly related to https://github.com/cython/cython/issues/4461. We seem to be building with the newest Cython (0.29.34) which supposedly solves things but doesn't appear to in our case.

      [1/4] Cythonizing capnpy/packing.pyx
      [2/4] Cythonizing capnpy/segment/base.pyx
      [3/4] Cythonizing capnpy/segment/builder.pyx
      [4/4] Cythonizing capnpy/_hash.pyx
      building 'capnpy.segment.base' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/capnpy
      creating build/temp.linux-x86_64-cpython-311/capnpy/segment
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/pip-install-kyeri00_/capnpy_6c6a984da1bc4a1cb9c15350e1d81411/capnpy -I/pyenv/versions/3.11.2/include/python3.11 -c capnpy/segment/base.c -o build/temp.linux-x86_64-cpython-311/capnpy/segment/base.o -O3
      gcc -pthread -shared -L/pyenv/versions/3.11.2/lib -Wl,-rpath,/pyenv/versions/3.11.2/lib -L/pyenv/versions/3.11.2/lib -Wl,-rpath,/pyenv/versions/3.11.2/lib build/temp.linux-x86_64-cpython-311/capnpy/segment/base.o -L/pyenv/versions/3.11.2/lib -o build/lib.linux-x86_64-cpython-311/capnpy/segment/base.cpython-311-x86_64-linux-gnu.so
      building 'capnpy.segment.segment' extension
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/pip-install-kyeri00_/capnpy_6c6a984da1bc4a1cb9c15350e1d81411/capnpy -I/pyenv/versions/3.11.2/include/python3.11 -c capnpy/segment/segment.c -o build/temp.linux-x86_64-cpython-311/capnpy/segment/segment.o -O3
      capnpy/segment/segment.c:216:12: fatal error: longintrepr.h: No such file or directory
        216 |   #include "longintrepr.h"
            |            ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
kvelicka commented 1 year ago

Hi.

For sake of documentation: there seems to be another issue, seemingly related to cython/cython#4461. We seem to be building with the newest Cython (0.29.34) which supposedly solves things but doesn't appear to in our case.

      [1/4] Cythonizing capnpy/packing.pyx
      [2/4] Cythonizing capnpy/segment/base.pyx
      [3/4] Cythonizing capnpy/segment/builder.pyx
      [4/4] Cythonizing capnpy/_hash.pyx
      building 'capnpy.segment.base' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/capnpy
      creating build/temp.linux-x86_64-cpython-311/capnpy/segment
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/pip-install-kyeri00_/capnpy_6c6a984da1bc4a1cb9c15350e1d81411/capnpy -I/pyenv/versions/3.11.2/include/python3.11 -c capnpy/segment/base.c -o build/temp.linux-x86_64-cpython-311/capnpy/segment/base.o -O3
      gcc -pthread -shared -L/pyenv/versions/3.11.2/lib -Wl,-rpath,/pyenv/versions/3.11.2/lib -L/pyenv/versions/3.11.2/lib -Wl,-rpath,/pyenv/versions/3.11.2/lib build/temp.linux-x86_64-cpython-311/capnpy/segment/base.o -L/pyenv/versions/3.11.2/lib -o build/lib.linux-x86_64-cpython-311/capnpy/segment/base.cpython-311-x86_64-linux-gnu.so
      building 'capnpy.segment.segment' extension
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tmp/pip-install-kyeri00_/capnpy_6c6a984da1bc4a1cb9c15350e1d81411/capnpy -I/pyenv/versions/3.11.2/include/python3.11 -c capnpy/segment/segment.c -o build/temp.linux-x86_64-cpython-311/capnpy/segment/segment.o -O3
      capnpy/segment/segment.c:216:12: fatal error: longintrepr.h: No such file or directory
        216 |   #include "longintrepr.h"
            |            ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

Resolving this may be as simple as merging https://github.com/antocuni/capnpy/pull/61/files