WillFurnass | 24 Oct 16:38 2014
Picon

Debugging: unsupported operand type(s) for +=: 'NoneType' and 'str when using 'gdb_debug=True'

Hi,

I'd like to debug some cython code.  However, when I try to enable cygdb debugging in my my setup.py using

setup(...ext_modules=cythonize(ext_modules, gdb_debug=True))

I get the following error:

$ pip install -U .
Unpacking /home/will/Dropbox/PhD/Discol_and_regen/VCDM/pyvcdm
  Running setup.py (path:/tmp/pip-hpidgegn-build/setup.py) egg_info for package from file:///home/will/Dropbox/PhD/Discol_and_regen/VCDM/pyvcdm
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-hpidgegn-build/setup.py", line 64, in <module>
        ext_modules=cythonize(ext_modules, gdb_debug=True),
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Build/Dependencies.py", line 840, in cythonize
        cythonize_one(*args[1:])
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Build/Dependencies.py", line 942, in cythonize_one
        result = compile([pyx_file], options)
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 629, in compile
        return compile_multiple(source, options)
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 607, in compile_multiple
        result = run_pipeline(source, options, context=context)
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Compiler/Main.py", line 438, in run_pipeline
        pipeline = Pipeline.create_pyx_pipeline(context, options, result)
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Compiler/Pipeline.py", line 231, in create_pyx_pipeline
        options.output_dir)
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/site-packages/Cython/Debugger/DebugWriter.py", line 45, in __init__
        self.output_dir = os.path.join(output_dir, 'cython_debug')
      File "/home/will/.virtualenvs/spstack34/lib/python3.4/posixpath.py", line 83, in join
        path += b
    TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

Anyone got any suggestions?  NB I'm using the following: python 3.4, cython 0.21.1, pip 1.5.6, setuptools 7.0, gdb 7.7.  python3.4-dbg is installed.  ext_modules is a list of Cython.Distutils.extension.Extension objects.

Regards,

Will

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jan93 | 24 Oct 16:01 2014
Picon

Embed pyside module

My python script is importing pyside module.
I'm using "--embed" and then I compile the script to executable.
My goal is that the executable will not ask for pyside module.
It is possible to embed pyside module together with my script.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
yi huang | 24 Oct 08:24 2014
Picon

Need advice to share extension type definitions between different packages.

Say i want to cimport some cython extension types defined in other package(kivy), it seems i need to copy their definitions, or compile with kivy altogether. Or i supposed to use python interface only?
What's your advice?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Emmanuel Gil Peyrot | 22 Oct 22:21 2014
Picon

PyPy3 and Cython

Hi,

When I try to run my codebase on top of PyPy3, I get an “undefined
symbol: PyDict_GetItemWithError” error.

Probably a few more #ifdef are needed in order to account for cpyext
even in Python3 mode.

If you want to test it, you can clone http://hg.linkmauve.fr/touhou and
run `pypy3 setup.py build_ext`, but I guess any python script using a
dict would have the same issue.

--

-- 
Emmanuel Gil Peyrot
Aditya Ghantasala | 22 Oct 16:36 2014
Picon

compile to get .cpp and .h files and linking them with other C++ program

Hello People

I am very new to cython. From what I understood, I wrote a small .pyx file with some cdef public variables and cdef public functions.
Then I used cython --cplus myScript.pyx  and get a .h and .cpp files.
Now I want to use these functions in an another .cpp file by including .h file.

First question is ... is it possible to do it ?
I tried to compile it and am stuck with the compiler complaining that it expects a constructor and destructor.  before the functions.

I am attaching my files with this post. Any suggestions to make it working .. ??
I am using python 3.3

Thanks in advance and Regards
Aditya.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Attachment (cy_mod.pyx): application/octet-stream, 248 bytes
Attachment (cy_exp.cpp): text/x-c++src, 348 bytes
Attachment (cy_mod.cpp): text/x-c++src, 61 KiB
Attachment (cy_mod.h): text/x-chdr, 556 bytes
Attachment (cy_mod.pyx): application/octet-stream, 248 bytes
Julien Delafontaine | 21 Oct 16:44 2014
Picon

Distributing a script in a Cython module

Hello,

I packaged a Cython module that contains a command-line script. Because I declare it with "scripts=[...]" in setuptools, it gets installed at some random place (/usr/local/bin/) outside of the module when I execute the setup.py.
Now I need to import my functions in this script, tried everything and it is driving me crazy. I suppose it is Cython-specific because I follow the same steps as everybody else and it works for them otherwise.
The arborescence of the package is as follows:

myapp            (package name)
-myapp           (module name)
----__init__.py
----myapp         (the script)
----myapp.pyx
----myapp.c
-dist
-build
----...                   (.so and stuff)
----scripts-2.7/myapp    (built script)


How can I import functions from the .so inside my script so that they remain available after installation (pip install...) ?
So far on top of my script I tried both

import myapp
from myapp import myapp

to call a method

myapp.method

"import myapp" never works, but I'd like to make it work... 
"from myapp import myapp" works for my local installation (setup.py) but not through "pip install".
After installation with "pip install", it is still possible to "import myapp" in a python console but it has no user defined contents and points to the __init__.py, or some get only "No module named myapp".

Can you help me with this ?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Abbeville | 21 Oct 14:13 2014
Picon

Cythonizing Python objects

Want to understand what is the most efficient way to cythonize common python objects wrt performance.  For example:

my_list = ['what', 'a', 'hoot', 'this' 'is']

To iterate through my_list, we can use standard Python as:

for word in my_list:
    <do stuff>

With cython, we can use the above code as-is or add type information as:

for i in range(len(my_list)):
    cdef unsigned int i
    word = my_list[i]
    <do stuff>

Next, consider a dictionary:

my_dict = {9:'what', 5:'a', 3:'hoot', 7:'this' 1:'is'}

To iterate through my_dict to get both the key and value, we can use standard Python as:

for k, v in my_dict.items():
    <do stuff>

With cython, we can use the above code as-is or add type information as:

keys = my_dict.keys()
for i in range(len(my_dict)):
    cdef unsigned int i, k
    
    k = keys[i]
    v = my_dict[k]
    <do stuff>

Is the cythonizing of the list and dictionary iteration correct wrt improving performance?

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Abbeville | 20 Oct 12:44 2014
Picon

AttributeError: 'module' object has no attribute 'locals'

Getting this error with cython (0.21 & 0.21.1) from Anaconda (2.1) on both windows and linux

> python do_cythonize.py build_ext --inplace

Traceback (most recent call last):
  File "do_cythonize.py", line 14, in <module>
    from Cython.Build import cythonize
  File "C:\Anaconda\lib\site-packages\Cython\Build\__init__.py", line 1, in <module>
    from .Dependencies import cythonize
  File "C:\Anaconda\lib\site-packages\Cython\Build\Dependencies.py", line 148, in <module>
    <at> cython.locals(start=long, end=long)
AttributeError: 'module' object has no attribute 'locals'
Exception KeyError: KeyError(26750608,) in <module 'threading' from 'C:\Anaconda\lib\threading.pyc'> ignored

do_cythonize.py

import numpy
from distutils.core import setup
from Cython.Build import cythonize 
 
ext_modules = cythonize(["config.pyx"])
 
setup(
    ext_modules = ext_modules, 
    include_dirs=[numpy.get_include()]

Any idea what the problem is? Thx.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
1989lzhh | 20 Oct 07:06 2014
Picon

The type inference of Memoryview slice is not supported in cython

Hi,
I find that the type inference of  memoryview slice and index is not supported in the current cython. I look up
the source code and find 'analyses_types' method in the IndexNode have the ability to infer memoryview
slice. It seems this method have the same ability with 'infer_type' method, right?
Regards,
Liu zhenhai

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Bammer | 20 Oct 06:57 2014
Picon

Re: Cython 0.21.1 released

When I try to execute a file (without compiling) which contains:

<at> cython.returns(cython.unicode)

It will fail with an error that unicode is not defined in module cython.
But compiling the source file and executing the compiled file succeeds.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeroen Demeyer | 19 Oct 21:08 2014
Picon

Re: Repeating cdef declarations in derived classes

On 2014-10-18 16:31, Stefan Behnel wrote:
>> Is there even a difference between
>>
>> cdef class Derived(Base):
>>      cdef int foo()
>>      cdef int bar()
>>
>> and
>>
>> cdef class Derived(Base):
>>      cdef int bar()
>
> Yes. It's as in Python. If you redefine a method in a derived class, it
> gets overwritten.
My original question was not so clear, I meant for .pxd declarations.
Does it make a difference there?

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Gmane