[Cython] [Desired feature] Process .pxd before .py

2014-08-28 Thread Alexandru Ionut Grama
Hello to all

I've start to use cython in order to use call some API modules written in
python from C/C++. Those modules written in python must remain untouched,
and all .py files should be "decorated" with their counterpart .pxd files.
I would like to mark as public some API functions from .py files, following
the indications from http://docs.cython.org/src/tutorial/pxd_files.html.
I've started to write a little example:

suma_alex.py:
def suma_Alex(a,b):
return a+b

suma_alex.pxd:
cdef public int suma_Alex(int a,int b)


The combination of those two files should turn into something like this for
the compiler:

cdef public int suma_Alex(int a,int b):
  return a+b

On generated .h file I should obtain a function prototype like this:
__PYX_EXTERN_C DL_IMPORT(int) suma_Alex(int, int);

Instead of that, I obtain a prototype like this:
__PYX_EXTERN_C DL_IMPORT(int) __pyx_f_10suma_alex_suma_Alex(int, int);

Digging into code and executing cythonize with pdb, I followed that is
executed a pipeline for .py file before .pxd file's pipeline. Correct me if
I'm wrong, but this makes the name of .c function be generated according to
py file instead of pxd file. That makes an add of string
"__pyx_f_10suma_alex_" before function name, because the compiler doesn't
know about "public" key (on python doesn't exists). Including public key on
a pxd file for this function makes the compiler remove "static" key and
generate a .h file, but doesn't change the name prototype into a simple
"suma_Alex".

If I use cython on a pyx file containing the code below, it works perfectly
as expected.
cdef public int suma_Alex(int a,int b):
  return a+b

The questions are:
- I'm doing what I want to do on a right way?
- Is this feature included on cython development version? I've tried on
0.20.2
- If is not implemented, I want to colaborate implementing it. Could you
please provide me some guidelines with the methods/modules that I should
modify?

King regards,
Alexandru.

-- 


*---Alexandru
Ionut Grama**email: gramaalexandruio...@gmail.com
*
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] error LNK2001: unresolved external symbol PyInit_init

2014-08-28 Thread Stefan Behnel
Andriy Kornatskyy schrieb am 27.08.2014 um 07:08:
> Here is a link to complete output with python3.4:
> https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152

What Lisandro meant with "complete" is "from entering the build command to
the point where it fails".

Stefan

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


Re: [Cython] error LNK2001: unresolved external symbol PyInit_init

2014-08-28 Thread Andriy Kornatskyy
Stefan,

Hmm… you have a complete build log from the entering the build command up to 
the point where it fails which you can still find here:

https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152

Or am I missing something?

Thanks.

Andriy Kornatskyy

On Aug 28, 2014, at 10:29 AM, Stefan Behnel  wrote:

> Andriy Kornatskyy schrieb am 27.08.2014 um 07:08:
>> Here is a link to complete output with python3.4:
>> https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
> 
> What Lisandro meant with "complete" is "from entering the build command to
> the point where it fails".
> 
> Stefan
> 
> ___
> cython-devel mailing list
> cython-devel@python.org
> https://mail.python.org/mailman/listinfo/cython-devel

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


Re: [Cython] error LNK2001: unresolved external symbol PyInit_init

2014-08-28 Thread Stefan Behnel
Andriy Kornatskyy schrieb am 28.08.2014 um 10:08:
> Hmm… you have a complete build log from the entering the build command up to 
> the point where it fails which you can still find here:
> 
> https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152

Sorry, where? All I see is the command and then the linker command, no
Cython build call, no C compiler build call, no distutils output.

Stefan

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


Re: [Cython] error LNK2001: unresolved external symbol PyInit_init

2014-08-28 Thread Andriy Kornatskyy
Stefan,

That is an output of build:

python setup.py build.

There is nothing else produced unless you tell how to make it more verbose to 
provide you what you expect to see. How else you want this to be built?

Thanks.

Andriy Kornatskyy

On Aug 28, 2014, at 1:46 PM, Stefan Behnel  wrote:

> Andriy Kornatskyy schrieb am 28.08.2014 um 10:08:
>> Hmm… you have a complete build log from the entering the build command up to 
>> the point where it fails which you can still find here:
>> 
>> https://bitbucket.org/akorn/wheezy.template/issue/10/installation-on-windows-fails#comment-12006152
> 
> Sorry, where? All I see is the command and then the linker command, no
> Cython build call, no C compiler build call, no distutils output.
> 
> Stefan
> 
> ___
> cython-devel mailing list
> cython-devel@python.org
> https://mail.python.org/mailman/listinfo/cython-devel

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


Re: [Cython] [Desired feature] Process .pxd before .py

2014-08-28 Thread Stefan Behnel
Alexandru Ionut Grama schrieb am 26.08.2014 um 17:45:
> I've start to use cython in order to use call some API modules written in
> python from C/C++. Those modules written in python must remain untouched,
> and all .py files should be "decorated" with their counterpart .pxd files.
> I would like to mark as public some API functions from .py files, following
> the indications from http://docs.cython.org/src/tutorial/pxd_files.html.
> I've started to write a little example:
> 
> suma_alex.py:
> def suma_Alex(a,b):
> return a+b
> 
> suma_alex.pxd:
> cdef public int suma_Alex(int a,int b)
> 
> 
> The combination of those two files should turn into something like this for
> the compiler:
> 
> cdef public int suma_Alex(int a,int b):
>   return a+b
> 
> On generated .h file I should obtain a function prototype like this:
> __PYX_EXTERN_C DL_IMPORT(int) suma_Alex(int, int);
> 
> Instead of that, I obtain a prototype like this:
> __PYX_EXTERN_C DL_IMPORT(int) __pyx_f_10suma_alex_suma_Alex(int, int);

Looks like a bug to me. There is a step in the pipeline that merges the
.pxd file declarations into those found in the main source file. Either the
"public" modifier is not properly copied over or the cname needs to be
updated when merging in the override declarations.

Stefan

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


Re: [Cython] error LNK2001: unresolved external symbol PyInit_init

2014-08-28 Thread Stefan Behnel
Lisandro Dalcin schrieb am 24.08.2014 um 10:57:
> On 14 August 2014 08:20, Andriy Kornatskyy wrote:
>> When installing either from pip3 or downloading the source with python3 
>> setup.py install
> 
> Could you please show us the full output of "python3 setup.py build" ?

It's here:

http://pastebin.com/vZb2gAvL

The other modules build fine, only the package script fails to link. The
problem is the "/EXPORT:PyInit___init__" flag, whereas the real name of the
module init function is (or should be) "PyInit_template", which is the name
of the package.

Does anyone have a good idea how to fix this? Looks like a distutils issue.
I don't think package compilation was originally envisioned as something
extension module authors would want to do.

Does the "cythonize_script_package" test work on MSWindows? It does the
same thing.

Stefan

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


[Cython] timeframe for subtype support in freelists? (was: Cython 0.21 beta 1 released)

2014-08-28 Thread Stefan Behnel
Peter Schay schrieb am 19.08.2014 um 00:46:
> One question: Is there any expected time-frame for freelists to support 
> cdef subclasses?  Soon? Never?  Somewhere in between?

Hard to say. This isn't easy as supporting subtypes means that we need full
control over what the parent types are doing in their
allocation/deallocation chain, and that may not be entirely trivial to
determine. The current call chain isn't made for that.

In any case, no-one's currently working on this AFAIK.

Stefan

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


Re: [Cython] [cython-users] Cython 0.21 alpha 1 released

2014-08-28 Thread Stefan Behnel
Hi,

here is a second beta:

http://www.cython.org/release/Cython-0.21b2.tar.gz

http://www.cython.org/release/Cython-0.21b2.tar.gz.asc

Since the last beta, there were a couple of improvements for the new method
call optimisation, as well as some fixes (usually noted in the relevant
mailing list threads already).

We might have forgotten to mention previously that inner functions are
supported inside of cdef functions in 0.21, a feature that I consider worth
noting (and testing :).

Complete changelog:

https://github.com/cython/cython/blob/d4b87c6d818406275905c87cf89479bebff53c6f/CHANGES.rst

This would be a good time to bump any pending bug reports that you think
should be considered for this release.

Stefan

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


Re: [Cython] [Desired feature] Process .pxd before .py

2014-08-28 Thread Alexandru Ionut Grama
2014-08-28 16:57 GMT+02:00 Stefan Behnel :

> Alexandru Ionut Grama schrieb am 26.08.2014 um 17:45:
> > I've start to use cython in order to use call some API modules written in
> > python from C/C++. Those modules written in python must remain untouched,
> > and all .py files should be "decorated" with their counterpart .pxd
> files.
> > I would like to mark as public some API functions from .py files,
> following
> > the indications from http://docs.cython.org/src/tutorial/pxd_files.html.
> > I've started to write a little example:
> >
> > suma_alex.py:
> > def suma_Alex(a,b):
> > return a+b
> >
> > suma_alex.pxd:
> > cdef public int suma_Alex(int a,int b)
> >
> >
> > The combination of those two files should turn into something like this
> for
> > the compiler:
> >
> > cdef public int suma_Alex(int a,int b):
> >   return a+b
> >
> > On generated .h file I should obtain a function prototype like this:
> > __PYX_EXTERN_C DL_IMPORT(int) suma_Alex(int, int);
> >
> > Instead of that, I obtain a prototype like this:
> > __PYX_EXTERN_C DL_IMPORT(int) __pyx_f_10suma_alex_suma_Alex(int, int);
>
> Looks like a bug to me.

There is a step in the pipeline that merges the
> .pxd file declarations into those found in the main source file. Either the
> "public" modifier is not properly copied over or the cname needs to be
> updated when merging in the override declarations.
>

Hi Stefan,
Thanks for the answer at first.
If is a bug, do you need more information in order to check it? Could you
tell me the methods that are used to merge the override declarations for
investigate by myself and create a patch to correct the bug?

Is there a workaround that maybe solve this?

King regards,
Alexandru



> Stefan
>
> ___
> cython-devel mailing list
> cython-devel@python.org
> https://mail.python.org/mailman/listinfo/cython-devel
>



-- 


*---Alexandru
Ionut Grama**email: gramaalexandruio...@gmail.com
*
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Cython 0.21 beta 1 released

2014-08-28 Thread Stefan Behnel
Hi,

thanks for testing.

Arfrever Frehtes Taifersar Arahesis schrieb am 14.08.2014 um 10:18:
> Results of test suite of Cython 0.21 beta 1 with different versions of Python:
>   Python 2.6: 1 error, 2 failures
>   Python 2.7: 1 error, 0 failures
>   Python 3.2: 1 error, 0 failures
>   Python 3.3: 1 error, 0 failures
>   Python 3.4: 1 error, 0 failures
> 
> The 1 error is the same with all versions of Python.
> Output with Python 2.6:
> 
> ==
> ERROR: compiling (c) and running bufaccess
> --
> Traceback (most recent call last):
>   File "runtests.py", line 1022, in run
> check_thread_termination()
>   File "runtests.py", line 1633, in check_thread_termination
> raise PendingThreadsError("left-over threads found after running test")
> PendingThreadsError: left-over threads found after running test
> 
> ==

There should be some output in the log where the test is run that shows
what threads are still running here. Could you look that up?


> ==
> FAIL: Doctest: double_dealloc_T796
> --
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/doctest.py", line 2163, in runTest
> raise self.failureException(self.format_failure(new.getvalue()))
> AssertionError: Failed doctest test for double_dealloc_T796
>   File 
> "/tmp/Cython-0.21b1/tests-2.6/run/cpp/double_dealloc_T796/double_dealloc_T796.so",
>  line unknown line number, in double_dealloc_T796
> 
> --
> File 
> "/tmp/Cython-0.21b1/tests-2.6/run/cpp/double_dealloc_T796/double_dealloc_T796.so",
>  line ?, in double_dealloc_T796
> Failed example:
> del x
> Expected:
> SimpleGarbage(1) __dealloc__
> Collector.__dealloc__
> collect 0
> Got:
> SimpleGarbage(1) __dealloc__
> Collector.__dealloc__
> collect 128

This might just be a problem with the test. Does this patch help?

=
diff -r f7b5d79a04e6 -r e2f2cf8efcc7 tests/run/double_dealloc_T796.pyx
--- a/tests/run/double_dealloc_T796.pyx Thu Aug 28 20:21:14 2014 +0200
+++ b/tests/run/double_dealloc_T796.pyx Thu Aug 28 20:31:06 2014 +0200
@@ -1,4 +1,5 @@
 """
+>>> gc.collect()
 >>> x = SimpleGarbage()
 SimpleGarbage(1) __cinit__
 >>> del x
=

Stefan

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