Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile on Python 3.11 alpha 5 #288

Closed
domdfcoding opened this issue Feb 7, 2022 · 2 comments · Fixed by #371 or #381
Closed

Unable to compile on Python 3.11 alpha 5 #288

domdfcoding opened this issue Feb 7, 2022 · 2 comments · Fixed by #371 or #381
Assignees
Milestone

Comments

@domdfcoding
Copy link
Contributor

When running python3.11 -m pip wheel hpy --use-pep517 the output is as follows:

Collecting hpy
  Downloading hpy-0.0.3.tar.gz (172 kB)
     |████████████████████████████████| 172 kB 9.5 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: hpy
  Building wheel for hpy (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/domdf/.local/bin/python3.11 /home/domdf/python311/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmp4xeykvcx
       cwd: /tmp/pip-wheel-9n1000e1/hpy_bf00928872e2496a9d116bd1dd260d92
  Complete output (37 lines):
  fatal: not a git repository (or any of the parent directories): .git
  running bdist_wheel
  running build
  running build_py
  running egg_info
  writing hpy.egg-info/PKG-INFO
  writing dependency_links to hpy.egg-info/dependency_links.txt
  writing entry points to hpy.egg-info/entry_points.txt
  writing requirements to hpy.egg-info/requires.txt
  writing top-level names to hpy.egg-info/top_level.txt
  listing git files failed - pretending there aren't any
  reading manifest file 'hpy.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  adding license file 'LICENSE'
  running build_ext
  building 'hpy.universal' extension
  hpy/debug/src/debug_ctx_cpython.c: In function ‘debug_ctx_CallRealFunctionFromTrampoline’:
  hpy/debug/src/debug_ctx_cpython.c:162:20: error: dereferencing pointer to incomplete type ‘cpy_Py_buffer’ {aka ‘struct bufferinfo’}
    162 |             a->view->obj = NULL;
        |                    ^~
  hpy/debug/src/debug_ctx_cpython.c:165:36: warning: passing argument 3 of ‘_buffer_h2py’ from incompatible pointer type [-Wincompatible-pointer-types]
    165 |         _buffer_h2py(dctx, &hbuf, a->view);
        |                                   ~^~~~~~
        |                                    |
        |                                    cpy_Py_buffer * {aka struct bufferinfo *}
  hpy/debug/src/debug_ctx_cpython.c:41:78: note: expected ‘Py_buffer *’ {aka ‘struct <anonymous> *’} but argument is of type ‘cpy_Py_buffer *’ {aka ‘struct bufferinfo *’}
     41 | static void _buffer_h2py(HPyContext *dctx, const HPy_buffer *src, Py_buffer *dest)
        |                                                                   ~~~~~~~~~~~^~~~
  hpy/debug/src/debug_ctx_cpython.c:173:29: warning: passing argument 2 of ‘_buffer_py2h’ from incompatible pointer type [-Wincompatible-pointer-types]
    173 |         _buffer_py2h(dctx, a->view, &hbuf);
        |                            ~^~~~~~
        |                             |
        |                             cpy_Py_buffer * {aka struct bufferinfo *}
  hpy/debug/src/debug_ctx_cpython.c:56:61: note: expected ‘const Py_buffer *’ {aka ‘const struct <anonymous> *’} but argument is of type ‘cpy_Py_buffer *’ {aka ‘struct bufferinfo *’}
     56 | static void _buffer_py2h(HPyContext *dctx, const Py_buffer *src, HPy_buffer *dest)
        |                                            ~~~~~~~~~~~~~~~~~^~~
  error: command '/usr/bin/gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for hpy
Failed to build hpy
ERROR: Failed to build one or more wheels

The output is more or less the same when building from git, with some of the line numbers changing.


It looks like bufferinfo was removed in python/cpython#29991, which made it into alpha 5.

It's used here:

typedef struct bufferinfo cpy_Py_buffer;

@steve-s
Copy link
Contributor

steve-s commented Mar 11, 2022

AFAICS cpy_types.h tries to forward declare types from Python.h? It does that for Py_buffer too:

/* generally speaking, we can't #include Python.h, but there are a bunch of
 * types defined there that we need to use.  Here, we redefine all the types
 * we need, with a cpy_ prefix.
 */

typedef struct _object cpy_PyObject;
// ...
typedef struct bufferinfo cpy_Py_buffer;

the bufferinfo tag was, however, removed, so in Include/buffer.h it is not:

typedef struct bufferinfo {
  // ...
} Py_buffer;

but:

typedef struct {
  // ...
} Py_buffer;

@antocuni any suggestions?

@timfel timfel added this to the Version 0.9 milestone Nov 1, 2022
@fangerer fangerer reopened this Nov 24, 2022
@fangerer
Copy link
Contributor

Just tried to build with Python 3.11.0 and got this:

hpy/devel/src/runtime/ctx_type.c:657:58: error: declaration of 'struct bufferinfo' will not be visible outside of this function [-Werror,-Wvisibility]
typedef int (*HPyGetBufferProc)(struct _object *, struct bufferinfo *, int);
                                                         ^
hpy/devel/src/runtime/ctx_type.c:658:63: error: declaration of 'struct bufferinfo' will not be visible outside of this function [-Werror,-Wvisibility]
typedef void (*HPyReleaseBufferProc)(struct _object *, struct bufferinfo *);
                                                              ^
hpy/devel/src/runtime/ctx_type.c:677:48: error: incompatible function pointer types assigning to 'getbufferproc' (aka 'int (*)(struct _object *, Py_buffer *, int)') from 'HPyGetBufferProc' (aka 'int (*)(struct _object *, struct bufferinfo *, int)') [-Werror,-Wincompatible-function-pointer-types]
                    buffer_procs->bf_getbuffer = (HPyGetBufferProc)src->slot.cpy_trampoline;
                                               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hpy/devel/src/runtime/ctx_type.c:687:52: error: incompatible function pointer types assigning to 'releasebufferproc' (aka 'void (*)(struct _object *, Py_buffer *)') from 'HPyReleaseBufferProc' (aka 'void (*)(struct _object *, struct bufferinfo *)') [-Werror,-Wincompatible-function-pointer-types]
                    buffer_procs->bf_releasebuffer = (HPyReleaseBufferProc)src->slot.cpy_trampoline;
                                                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants