sergey-dryabzhinsky / python-zstd

Simple python bindings to Yann Collet ZSTD compression library
BSD 2-Clause "Simplified" License
165 stars 27 forks source link

Compile fails on MacOS with pypy 3.9 #76

Closed Askaholic closed 2 years ago

Askaholic commented 2 years ago

I'm building my package with cibuildwheel across multiple OS's and python versions and I have zstd as an optional dependency. The zstd build seems to be failing on the combination of MacOS and pypy 3.9. Ubuntu and Windows + pypy 3.9 both seem to be working, only MacOS is failing. Also MacOS with pypy 3.7 seemed to have worked.

OS: MacOS 10.9 Python version: pypy 3.9.12 zstd: 1.5.2.0

Error log:

     Running setup.py install for zstd: started
    Running setup.py install for zstd: finished with status 'error'
    error: subprocess-exited-with-error

    × Running setup.py install for zstd did not run successfully.
    │ exit code: 1
    ╰─> [30 lines of output]
        running install
        /Users/runner/work/faf-replay-parser-python/faf-replay-parser-python/.tox/pypy39/lib/pypy3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        running build
        running build_ext
        building 'zstd' extension
        creating build
        creating build/temp.macosx-10.9-x86_64-pypy39
        creating build/temp.macosx-10.9-x86_64-pypy39/src
        creating build/temp.macosx-10.9-x86_64-pypy39/zstd
        creating build/temp.macosx-10.9-x86_64-pypy39/zstd/lib
        creating build/temp.macosx-10.9-x86_64-pypy39/zstd/lib/common
        creating build/temp.macosx-10.9-x86_64-pypy39/zstd/lib/compress
        creating build/temp.macosx-10.9-x86_64-pypy39/zstd/lib/decompress
        gcc -pthread -arch x86_64 -DNDEBUG -O2 -fPIC -I/Users/runner/work/faf-replay-parser-python/faf-replay-parser-python/.tox/pypy39/include -I/Users/runner/hostedtoolcache/PyPy/3.9.12/x64/include/pypy3.9 -c src/python-zstd.c -o build/temp.macosx-10.9-x86_64-pypy39/src/python-zstd.o -O2 -DVERSION=1.5.2.0 -DDYNAMIC_BMI2=0 -DZSTD_MULTITHREAD=1 -Izstd/lib -Izstd/lib/common -Izstd/lib/compress -Izstd/lib/decompress -DZSTD_TRACE=0
        In file included from src/python-zstd.c:41:
        src/pythoncapi_compat.h:170:41: error: implicit declaration of function 'PyFrame_GetCode' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            return (PyCodeObject *)_Py_StealRef(PyFrame_GetCode(frame));
                                                ^
        src/pythoncapi_compat.h:170:28: warning: cast to 'PyObject *' (aka 'struct _object *') from smaller integer type 'int' [-Wint-to-pointer-cast]
            return (PyCodeObject *)_Py_StealRef(PyFrame_GetCode(frame));
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        src/pythoncapi_compat.h:74:41: note: expanded from macro '_Py_StealRef'
        #define _Py_StealRef(obj) __Py_StealRef(_PyObject_CAST(obj))
                                                ^~~~~~~~~~~~~~~~~~~
        /Users/runner/hostedtoolcache/PyPy/3.9.12/x64/include/pypy3.9/object.h:32:29: note: expanded from macro '_PyObject_CAST'
        #define _PyObject_CAST(op) ((PyObject*)(op))
                                    ^~~~~~~~~~~~~~~
        1 warning and 1 error generated.
        error: command '/usr/bin/gcc' failed with exit code 1
        [end of output]

The full CI log is here: https://github.com/Askaholic/faf-replay-parser-python/runs/6051537985?check_suite_focus=true

Supporting pypy is mostly just a curiosity for me, so I don't mind ignoring this combination in my builds if it's not easy to fix.

sergey-dryabzhinsky commented 2 years ago

Seems like pypy not fully implemented 3.9 release / bpo-40421. I added quick fix in 1.5.2.1. Can you check if it compiles now?

Askaholic commented 2 years ago

It worked with zstd 1.5.2.2: https://github.com/Askaholic/faf-replay-parser-python/runs/6055403460?check_suite_focus=true

sergey-dryabzhinsky commented 2 years ago

As I hoped.