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

Missing Python.h in generated header #3133

Closed
gerion0 opened this issue Sep 6, 2019 · 1 comment
Closed

Missing Python.h in generated header #3133

gerion0 opened this issue Sep 6, 2019 · 1 comment

Comments

@gerion0
Copy link
Contributor

gerion0 commented Sep 6, 2019

Consider the following minimal example:

foo.pyx

# cython: language_level=3
from cpython.ref cimport PyObject

cdef public struct Foo:
    PyObject* bar

Compiling this with:

cython --cplus foo.pyx -o foo.cpp

results in an foo.h header. Embedding this standalone, e.g.:
main.c

#include "foo.h"

int main() {
        return 0;
}

does not compile (since `#include "Python.h" is missing):

% g++ main.c
In file included from main.c:1:
foo.h:15:3: error: 'PyObject' does not name a type
   15 |   PyObject *bar;
      |   ^~~~~~~~
In file included from main.c:1:
foo.h:43:1: error: 'PyMODINIT_FUNC' does not name a type
   43 | PyMODINIT_FUNC initfoo(void);
      | ^~~~~~~~~~~~~~

I saw the option --capi-reexport-cincludes that results in some includes. However, Python.h is still missing, when using it. Is there an existing way to embed this include in the header? Otherwise it would be nice if you modify the compiler to inlucde Python.h.

@scoder scoder closed this as completed in e987a08 Sep 6, 2019
@scoder
Copy link
Contributor

scoder commented Sep 6, 2019

Admittedly, not a big use case given that you probably can't make much use of the header file without importing "Python.h" yourself, but then, since the header file itself depends on it, why not make sure it's there?

@scoder scoder added this to the 3.0 milestone Sep 6, 2019
@scoder scoder modified the milestones: 3.0, 0.29.14 Oct 8, 2019
scoder added a commit that referenced this issue Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants