[Cython] Add includes to generated header files

2012-08-02 Thread Jeff Copeland
I'm working on some C++ projects and I'm using cython to embed python
code.  In an effort to make things easy for C++ devs not as familiar
with cython/python I've made a small change to insert #includes in
generated header files the same as is done in generated c code.  This
allows one who is using code processed with cython to just include the
header and not worry about any other headers that may be required to
match data types.

Not having these headers is especially problematic because otherwise
the error message presented at compilation can sometimes be quite
cryptic.

Patch is attached.  Any reason this should not be done?

Thanks,

Jeff


0001-Updated-to-include-headers-in-.h-file-when-generated.patch
Description: Binary data
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Add includes to generated header files

2012-08-02 Thread Jeff Copeland
On Thu, Aug 2, 2012 at 8:43 PM, Stefan Behnel  wrote:
> Jeff Copeland, 03.08.2012 02:18:
>> I'm working on some C++ projects and I'm using cython to embed python
>> code.  In an effort to make things easy for C++ devs not as familiar
>> with cython/python I've made a small change to insert #includes in
>> generated header files the same as is done in generated c code.  This
>> allows one who is using code processed with cython to just include the
>> header and not worry about any other headers that may be required to
>> match data types.
>>
>> Not having these headers is especially problematic because otherwise
>> the error message presented at compilation can sometimes be quite
>> cryptic.
>>
>> Patch is attached.  Any reason this should not be done?
>
> Hmm, didn't try your patch, but I guess it inserts includes for *all*
> header files that the module that exports the C-API uses internally, right?

Yes, you've got it.  Certainly quick and dirty to satisfy my immediate need.

> If so, I'm not sure that's always wanted. I see the advantage, sure, but it
> may expose a lot of implementation details that external code may not
> normally have to care about.
>
> On the other hand, if extension types are exported, for example, it's
> somewhat unlikely that their struct would compile without at least some of
> those header files, because they almost always wrap some kind of externally
> defined struct, pointer or whatever kind of other data type.

Exactly.

> That sounds to me like we should make it a configurable option, something
> like "capi_reexport_cincludes".

I like that thought.  The other thing I'd though of is perhaps some
syntax in the pyx itself to designate an include file as one that
should show in a generated header.  When I was looking for a solution
to the issue that's what I started looking for in the documents but of
course came up empty.  I figured it may be something like the case for
inclusion in the c file but with a public/api keyword thrown in:

cdef extern public from "spam.h":
pass

Syntax change would probably be more involved.  I'll have a go at
doing a patch with the option added.  Do you mean as a command-line
option to cython?

Jeff
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Add includes to generated header files

2012-08-11 Thread Jeff Copeland
On Thu, Aug 2, 2012 at 8:43 PM, Stefan Behnel  wrote:
> That sounds to me like we should make it a configurable option, something
> like "capi_reexport_cincludes".

Do mean as a command line option, or something else like a compiler directive?
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Add includes to generated header files

2012-08-11 Thread Jeff Copeland
On Sat, Aug 11, 2012 at 10:27 AM, Jeff Copeland  wrote:
> On Thu, Aug 2, 2012 at 8:43 PM, Stefan Behnel  wrote:
>> That sounds to me like we should make it a configurable option, something
>> like "capi_reexport_cincludes".
>
> Do mean as a command line option, or something else like a compiler directive?

I went ahead and added a command line option.

https://github.com/cython/cython/pull/142
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel