msgpack/msgpack-python

Build failed in Python 3.13.0a5

Opened this issue · 13 comments

Summary

Building wheel for msgpack has been failed while installing msgpack 1.0.8 with pip in CPython 3.13.0a5.

msgpack/_cmsgpack.cpp:19109:9: error: ‘CYTHON_METH_FASTCALL’ was not declared in this scope; did you mean ‘METH_FASTCALL’?

Environment

$ uname -vorm
6.5.0-26-generic #26-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar  5 21:19:28 UTC 2024 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.10
Release:        23.10
Codename:       mantic

$ gcc --version
gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ pip -V
pip 24.0 from /home/eggplants/.pyenv/versions/3.13.0a5/lib/python3.13/site-packages/pip (python 3.13)

$ python -V
Python 3.13.0a5

$ pip list
Package      Version
------------ -------
argcomplete  3.2.3
click        8.1.7
packaging    24.0
pip          24.0
pipx         1.4.3
platformdirs 4.2.0
userpath     1.9.2

pip install

$ pip install msgpack
Collecting msgpack
  Using cached msgpack-1.0.8.tar.gz (167 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: msgpack
  Building wheel for msgpack (pyproject.toml): started
  Building wheel for msgpack (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Building wheel for msgpack (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [42 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-313
      creating build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/__init__.py -> build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/fallback.py -> build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/ext.py -> build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/exceptions.py -> build/lib.linux-x86_64-cpython-313/msgpack
      running build_ext
      building 'msgpack._cmsgpack' extension
      creating build/temp.linux-x86_64-cpython-313
      creating build/temp.linux-x86_64-cpython-313/msgpack
      gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I. -I/home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t -c msgpack/_cmsgpack.cpp -o build/temp.linux-x86_64-cpython-313/msgpack/_cmsgpack.o
      msgpack/_cmsgpack.cpp:1366:72: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
       1366 | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
            |                                                                        ^
      In file included from /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/unicodeobject.h:1014,
                       from /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/Python.h:65,
                       from msgpack/_cmsgpack.cpp:16:
      /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/cpython/unicodeobject.h:10:37: note: declared here
         10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
            |                                     ^~~~~~~~~~
      msgpack/_cmsgpack.cpp: In function ‘size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE*)’:
      msgpack/_cmsgpack.cpp:1368:23: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
       1368 |     const Py_UNICODE *u_end = u;
            |                       ^~~~~
      /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/cpython/unicodeobject.h:10:37: note: declared here
         10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
            |                                     ^~~~~~~~~~
      msgpack/_cmsgpack.cpp: In function ‘int __Pyx_CheckKeywordStrings(PyObject*, const char*, int)’:
      msgpack/_cmsgpack.cpp:19109:9: error: ‘CYTHON_METH_FASTCALL’ was not declared in this scope; did you mean ‘METH_FASTCALL’?
      19109 |     if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kw))) {
            |         ^~~~~~~~~~~~~~~~~~~~
            |         METH_FASTCALL
      msgpack/_cmsgpack.cpp: In function ‘int __Pyx_ParseOptionalKeywords(PyObject*, PyObject* const*, PyObject***, PyObject*, PyObject**, Py_ssize_t, const char*)’:
      msgpack/_cmsgpack.cpp:19198:25: error: ‘CYTHON_METH_FASTCALL’ was not declared in this scope; did you mean ‘METH_FASTCALL’?
      19198 |     int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds));
            |                         ^~~~~~~~~~~~~~~~~~~~
            |                         METH_FASTCALL
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for msgpack
Failed to build msgpack
ERROR: Could not build wheels for msgpack, which is required to install pyproject.toml-based projects

Did you try that with the latest Cython release?

Did you try that with the latest Cython release?

I have just tried that. Is this correct?

$ pip install cython==3.0.9
Collecting cython
  Downloading Cython-3.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.2 kB)
Downloading Cython-3.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.5/3.5 MB 1.3 MB/s eta 0:00:00
Installing collected packages: cython
Successfully installed cython-3.0.9

$ pip list
Package      Version
------------ -------
argcomplete  3.2.3
click        8.1.7
Cython       3.0.9
packaging    24.0
pip          24.0
pipx         1.4.3
platformdirs 4.2.0
userpath     1.9.2

$ pip install msgpack
Collecting msgpack
  Using cached msgpack-1.0.8.tar.gz (167 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: msgpack
  Building wheel for msgpack (pyproject.toml): started
  Building wheel for msgpack (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Building wheel for msgpack (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [42 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-313
      creating build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/__init__.py -> build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/fallback.py -> build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/ext.py -> build/lib.linux-x86_64-cpython-313/msgpack
      copying msgpack/exceptions.py -> build/lib.linux-x86_64-cpython-313/msgpack
      running build_ext
      building 'msgpack._cmsgpack' extension
      creating build/temp.linux-x86_64-cpython-313
      creating build/temp.linux-x86_64-cpython-313/msgpack
      gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I. -I/home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t -c msgpack/_cmsgpack.cpp -o build/temp.linux-x86_64-cpython-313/msgpack/_cmsgpack.o
      msgpack/_cmsgpack.cpp:1366:72: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
       1366 | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
            |                                                                        ^
      In file included from /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/unicodeobject.h:1014,
                       from /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/Python.h:65,
                       from msgpack/_cmsgpack.cpp:16:
      /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/cpython/unicodeobject.h:10:37: note: declared here
         10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
            |                                     ^~~~~~~~~~
      msgpack/_cmsgpack.cpp: In function ‘size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE*)’:
      msgpack/_cmsgpack.cpp:1368:23: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
       1368 |     const Py_UNICODE *u_end = u;
            |                       ^~~~~
      /home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t/cpython/unicodeobject.h:10:37: note: declared here
         10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
            |                                     ^~~~~~~~~~
      msgpack/_cmsgpack.cpp: In function ‘int __Pyx_CheckKeywordStrings(PyObject*, const char*, int)’:
      msgpack/_cmsgpack.cpp:19109:9: error: ‘CYTHON_METH_FASTCALL’ was not declared in this scope; did you mean ‘METH_FASTCALL’?
      19109 |     if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kw))) {
            |         ^~~~~~~~~~~~~~~~~~~~
            |         METH_FASTCALL
      msgpack/_cmsgpack.cpp: In function ‘int __Pyx_ParseOptionalKeywords(PyObject*, PyObject* const*, PyObject***, PyObject*, PyObject**, Py_ssize_t, const char*)’:
      msgpack/_cmsgpack.cpp:19198:25: error: ‘CYTHON_METH_FASTCALL’ was not declared in this scope; did you mean ‘METH_FASTCALL’?
      19198 |     int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds));
            |                         ^~~~~~~~~~~~~~~~~~~~
            |                         METH_FASTCALL
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for msgpack
Failed to build msgpack
ERROR: Could not build wheels for msgpack, which is required to install pyproject.toml-based projects

I can not reproduce it.

I also use Ubuntu 23.10 and pyenv and python 3.13a5:

  gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I. -I/home/methane/.pyenv/versions/3.13.0a5/include/python3.13 -c msgpack/_cmsgpack.cpp -o build/temp.linux-x86_64-cpython-313/msgpack/_cmsgpack.o
  msgpack/_cmsgpack.cpp:1366:72: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
   1366 | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
        |                                                                        ^
  In file included from /home/methane/.pyenv/versions/3.13.0a5/include/python3.13/unicodeobject.h:1014,
                   from /home/methane/.pyenv/versions/3.13.0a5/include/python3.13/Python.h:65,
                   from msgpack/_cmsgpack.cpp:16:
  /home/methane/.pyenv/versions/3.13.0a5/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here
     10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
        |                                     ^~~~~~~~~~
  msgpack/_cmsgpack.cpp: In function ‘size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE*)’:
  msgpack/_cmsgpack.cpp:1368:23: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
   1368 |     const Py_UNICODE *u_end = u;
        |                       ^~~~~
  /home/methane/.pyenv/versions/3.13.0a5/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here
     10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
        |                                     ^~~~~~~~~~
  msgpack/_cmsgpack.cpp: In function ‘int __pyx_f_7msgpack_9_cmsgpack_6Packer__pack(__pyx_obj_7msgpack_9_cmsgpack_Packer*, PyObject*, __pyx_opt_args_7msgpack_9_cmsgpack_6Packer__pack*)’:
  msgpack/_cmsgpack.cpp:9250:10: warning: ‘__pyx_r’ may be used uninitialized [-Wmaybe-uninitialized]
   9250 |   return __pyx_r;
        |          ^~~~~~~
  msgpack/_cmsgpack.cpp:7154:7: note: ‘__pyx_r’ was declared here
   7154 |   int __pyx_r;
        |       ^~~~~~~
  g++ -shared -L/home/methane/.pyenv/versions/3.13.0a5/lib -Wl,-rpath,/home/methane/.pyenv/versions/3.13.0a5/lib -L/home/methane/.pyenv/versions/3.13.0a5/lib -Wl,-rpath,/home/methane/.pyenv/versions/3.13.0a5/lib build/temp.linux-x86_64-cpython-313/msgpack/_cmsgpack.o -L/home/methane/.pyenv/versions/3.13.0a5/lib -o build/lib.linux-x86_64-cpython-313/msgpack/_cmsgpack.cpython-313-x86_64-linux-gnu.so
  installing to build/bdist.linux-x86_64/wheel

CYTHON_METH_FASTCALL is defined in the _cmsgpack.cpp.
Doesn't your machine or C preprocessor broken?

Wait, wait, wait!!

-I/home/eggplants/.pyenv/versions/3.13.0a5/include/python3.13t

python3.13t? What is it? Didn't you just pyenv install 3.13.0a5?

No GIL build is really experimental preview. It is under heavily development and very far to stable yet.

Unless you can debug problems by yourself, do not use it.
When reporting issue relating to no-GIL, say so clearly.

cython/cython@a4a0f1e

This commit is in master branch, but not in 3.0.x branch.
So you need to use master branch of Cython manually.
And please don't ask "how to use?" question here. If you don't do it by yourself, you must not use no-GIL Python yet.

Yes, I built with:

PYTHON_CONFIGURE_OPTS="--enable-experimental-jit --disable-gil" pyenv install 3.13.0a5

And thank you for your suggestion. But building are failing with completely same error, even with cython/cython@a7b111f. I gave up building with NOGIL for now.

$ pip install 'git+https://github.com/cython/cython.git#a7b111f'
...
Successfully installed Cython-3.1.0a0

$ pip install msgpack
...
Failed to build msgpack
ERROR: Could not build wheels for msgpack, which is required to install pyproject.toml-based projects
jfolz commented
$ pip install cython==3.0.9
Collecting cython
  Downloading Cython-3.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.2 kB)
Downloading Cython-3.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.5/3.5 MB 1.3 MB/s eta 0:00:00
Installing collected packages: cython
Successfully installed cython-3.0.9

This seems odd. If your 3.13 env is setup correctly, why does pip download a wheel tagged with cp312?

Again, you should pay your energy and effort.
This is issue tracker. This is place to report and track issues.
This is not place to support newbies.

@jfolz I don't know, perhaps I mistakenly executed in different directory using pyenv local 3.12 against one executed pip install msgpack.

I've just tried to install cython==3.0.9 / cython/cython@a7b111f and msgpack==1.0.8 again under 3.13.0a5 with GIL:

$ python -V
Python 3.13.0a5

$ pip uninstall cython
Found existing installation: Cython 3.1.0a0
Uninstalling Cython-3.1.0a0:
  Would remove:
    /home/eggplants/.pyenv/versions/3.13.0a5/bin/cygdb
    /home/eggplants/.pyenv/versions/3.13.0a5/bin/cython
    /home/eggplants/.pyenv/versions/3.13.0a5/bin/cythonize
    /home/eggplants/.pyenv/versions/3.13.0a5/lib/python3.13/site-packages/Cython-3.1.0a0.dist-info/*
    /home/eggplants/.pyenv/versions/3.13.0a5/lib/python3.13/site-packages/Cython/*
    /home/eggplants/.pyenv/versions/3.13.0a5/lib/python3.13/site-packages/cython.py
    /home/eggplants/.pyenv/versions/3.13.0a5/lib/python3.13/site-packages/pyximport/*
Proceed (Y/n)? y
  Successfully uninstalled Cython-3.1.0a0

$ pip install cython==3.0.9
Collecting cython==3.0.9
  Using cached Cython-3.0.9-py2.py3-none-any.whl.metadata (3.2 kB)
Using cached Cython-3.0.9-py2.py3-none-any.whl (1.2 MB)
Installing collected packages: cython
Successfully installed cython-3.0.9

$ pip install msgpack==1.0.8
...
Failed to build msgpack
ERROR: Could not build wheels for msgpack, which is required to install pyproject.toml-based projects

$ pip install 'git+https://github.com/cython/cython.git#a7b111f'
Successfully installed Cython-3.1.0a0

$ pip install msgpack==1.0.8
...
Failed to build msgpack
ERROR: Could not build wheels for msgpack, which is required to install pyproject.toml-based projects

I will wait for support to be provided by cython.

@methane I'm sorry. If this issue is too noisy, please lock this Issue.

You shouldn't pip install msgpack. It doesn't use installed cython at all.

Download msgpack .tar.gz, unarchive it, read pyproject.toml and setup.py, understand how msgpack is built, and regenerate cpp file by yourself.
I don't teach concrete steps to you. Ask help on Pythonista Slack, Discord, or any other communities.

For the record, cython/cython@124e5a6 is committed in 3.0.x branch. So Cython 3.0.10 will fix it.