Joshua Moore-Oliva | 10 Aug 18:25 2014
Picon

Unresolved external symbol PyInit___init__

When I attempt to install wheezy.template (https://pypi.python.org/pypi/wheezy.template/) I get the following error

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL /nologo
 /INCREMENTAL:NO /LIBPATH:C:\Python34\libs /LIBPATH:C:\Python34\PCbuild /EXPORT:
PyInit___init__ build\temp.win32-3.4\Release\src\wheezy\template\__init__.obj /O
UT:build\lib.win32-3.4\wheezy\template\__init__.pyd /IMPLIB:build\temp.win32-3.4
\Release\src\wheezy\template\__init__.lib /MANIFESTFILE:build\temp.win32-3.4\Rel
ease\src\wheezy\template\__init__.pyd.manifest
LINK : error LNK2001: unresolved external symbol PyInit___init__
build\temp.win32-3.4\Release\src\wheezy\template\__init__.lib : fatal error LNK1
120: 1 unresolved externals
error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\
link.exe' failed with exit status 1120

From what I can tell from the setup.py this is installing with cython, and the file it is failing to compile is fairly simple


"""
"""

__version__ = '0.1.151'

# flake8: noqa

from wheezy.template.engine import Engine
from wheezy.template.ext.code import CodeExtension
from wheezy.template.ext.core import CoreExtension
from wheezy.template.loader import DictLoader
from wheezy.template.loader import FileLoader
from wheezy.template.loader import PreprocessLoader

Based on my rudimentary windows linker knowledge, it appears that the command that is failing is attempting to export the symbol "PyInit___init__". However, the generated __init__.c does not have that symbol defined within in.

Based on that, I thought this may be an issue with cython, so I was hoping for some feedback, or possibly explanation.

Thanks, Josh

--

---
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.
Christoff Kok | 7 Aug 15:58 2014
Picon

Manipulating C++ vector list in Cython.

Hi,

I am really struggling to find out how to do the following in Cython:

#cdef addVehicle(self, PyVehicle vehicle):
    #    cdef Vehicle* ptr = value.thisptr
    #    self.thisptr.vehicles.push_back(ptr)

property vehicles:
        "Contains the garages Vehicles."
        def __get__(self):
            return self.vehicleList
        def __set__(self, PyVehicle value):
            cdef Vehicle* ptr = value.thisptr # Type Error. cannot convert from Python object to Vehicle*
            self.thisptr.vehicles.push_back(ptr)
            #self.addVehicle(value)
            self.vehicleList.append(value)

# Type Error: value is only Python type, Cython cdef values not accesible?
# When using the line: "self.addVehicle(value)" instead of the 2 lines above it, it seems that the code should work perfectly, but I am receiving the same error. Is value in the vehicles __set__ property a Python class and thus does not have access to the Cython cdef methods? Is there a work around?

Kind Regards,
Christoff

--

---
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.
Björn Dahlgren | 2 Aug 21:46 2014
Picon

Using C name specification in cdef extern from "someheader.h" namespace "somenamespace"

Hi!

I seem to be unable to make C name specifications (http://docs.cython.org/src/userguide/external_C_code.html#resolving-naming-conflicts-c-name-specifications)
work with C++ callbacks from a namespace.

My failing attempt looks like this as a minimal example:


    cdef extern from "foo.h" namespace "foo":
        cdef
double cpp_add "add" (double, double)

exchanging:
    cpp_add "add"

for:
     add

works as expected (without renaming). Is renaming supposed to be supported here - or should I use pxd files?

(see https://gist.github.com/bjodah/6419aa57060bc94c3cdd for a complete example)

--

---
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.
Ivan Smirnov | 2 Aug 14:22 2014
Picon

Bug/issue tracker vs GitHub repo

Hi all,

This may be an inappropriate question or it may have been raised before, but I couldn't find any info in the mailiing list.

Is there a reason GitHub issues are not used for Cython development? Does anyone strongly oppose that? It seems to have worked out very well for large-scale Python-based projects like scikit-learn and pandas. Since the code is hosted on GitHub anyway, wouldn't it make it easier to track issues there as well? It seems much easier to post formatted code snippets / link to code / commits / pull requests / cross reference other issues / link to releases / milestones / assign tags to issues as compared to google groups. I think it also makes it easier for devs if general discussion and usage are separated from bug tracking.

In my personal view, the mailing list doesn't fit as a replacement for a proper bug/issue tracker (and vice versa!) as (1) people tend to discuss general things here (e.g. asking for best practices), and (2) it's too disorganized to serve as a tracker and very hard to navigate and/or post code / insert links to commits/code. I recall myself running into compiler crashes / ICE multiple times but I didn't report it because I had no idea where and how to do it (and I still don't) -- trac.cython.org seems half-dead and unmaintained and contains open tickets from 5 years ago, not sure if anyone actually actively uses it for current development (it maybe a matter of personal preference but it generally seems quite clunky and unintuitive).

Thanks!

Regards,
-I.

--

---
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.
Gregorio Bastardo | 1 Aug 12:53 2014
Picon

Buffer dtype mismatch error on Windows

Hi,

I created sample code to demonstrate the problem:
https://gist.github.com/gregorio-bastardo/f2be00493a5b8c186c08

The isse has been reported earlier on the list, but unfortunately got
no feedback:
https://groups.google.com/forum/#!msg/cython-users/ytfJDZ_1DAI/3QIJXiSj1REJ

Since then I tried out a newer gcc version (TDM32 gcc 4.8.1, w/ and
w/o -mno-ms-bitfields flag) and MSVC 2008 Express but no success. I
suspect it's a padding issue and tried to dig deeper (inspecting
generated code and map file), but had to stop due to time constraints.

I repeat my request as this issue is getting a blockage in our
development team, and w/o your support we might have to leave cython.
Therefore any help is appreciated.

Could anyone confirm this behavior? It's also helpful if other
platforms report it as non-issue.

Thank you,
Gregorio

--

-- 

--- 
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.

Stefan Behnel | 31 Jul 19:49 2014
Picon

Cython 0.21 alpha 1 released

Hi,

I uploaded a first alpha release of Cython 0.21.

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

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

There were a couple of major changes in this version, including internal
improvements to some basic syntax structures, so please give it a try with
your code to help us fix some more bugs before the final release.

Complete changelog:

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

Have fun,

Stefan

--

-- 

--- 
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.

maplefallingleaf | 31 Jul 13:31 2014
Picon

Compiling built-in python 3 module: is it useful? And how to do it in bulk?

I'm creating a Python 3 package for an ARM device (Kobo e-reader). Do you think it's of some use to compile the built-in modules using Cython?

If so, how can I pass the language_level=3 to the distutils without touching the module sources? Is there a way to modify also target path and output .so filename?

--

---
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.
Pierrick Koch | 30 Jul 18:19 2014
Picon

std::array

Hello,

I would like to wrap a C++11 class using vector<array<double,4>> with Cython.
According to [1] it should be possible, however when I try [2], I
still get the error:
"unknown type in template argument"

[1] https://groups.google.com/d/msg/cython-users/3VTyPot339c/2dXQfOvqLl0J
[2] https://gist.github.com/pierriko/fca8eebf49fca8336c50

I am just learning about Cython, any hints would be appreciated.
Best,
-- 
Pierrick Koch

--

-- 

--- 
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.

Christoff Kok | 30 Jul 11:44 2014
Picon

C++ wrapping code: Accessing a list of baseclass objects as derived objects in Python.

Hi,

I am having trouble to access a C++ base type as it's derived type in Python.
The reason I am trying to do this is that I have a list of base types which should serve as the access point to the derived types:
E.g.
C++ pseudocode:
VehicleGarage
    vector<Vehicle> vehicles

Vehicle
   virtual void foo()
   void baseMethod() { std::cout << "Base Method access"; }

Boat : Vehicle
    void foo() { std::cout << "Row, row"; }
    void float() { std::cout << "floating"; }

Hovercraft:Vehicle
    ...

Cython pseudocode:
VehicleGarage
    property vehicles: get return vehicles; # How to return vehicles as a list, each item of it's most derived type, e.g. boat, or hovercraft or car, etc.

Python pseudocode:
garage = VehicleGarage()
garage.vehicles.add(Boat())
garage.vehicles[0].float() # This is the result I want. It should print out: floating


This is a simple example. I could do type checks in boat, and then, through some if statements in the Cython code, return the correct type. I am however trying to avoid this (I'd rather have it happen automatically) as this will cost us and some of our users too much effort.

Regards,
Christoff

--

---
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.
Kurt Smith | 30 Jul 02:32 2014
Picon

Typed memoryview bug with stack-allocated C arrays

Hi all,

Does this fall under the territory of "bug," "undefined behavior", or "the user should be smart enough not to do this"?  I vote for "bug":

# memview_bug.pyx
import numpy as np

def quux():
    cdef int arr[10]
    cdef int[::1] mv = arr
    mv[...] = 0
    nparr = np.asarray(mv)
    print nparr
    return nparr


$ ipython
Python 2.7.3 (default, Dec 13 2012, 12:38:17)
Type "copyright", "credits" or "license" for more information.

IPython 1.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pyximport; pyximport.install()
Out[1]: (None, <pyximport.pyximport.PyxImporter at 0x101c66650>)

In [2]: import memview_bug

In [3]: arr = memview_bug.quux()
[0 0 0 0 0 0 0 0 0 0]

In [4]: arr
Out[4]:
array([        -1,         -1,          8,    3187136,          1,
               63,          0, 1109509176, 1992422258,    2386656], dtype=int32)

In [5]: arr[0] = 10**10

In [7]: arr[0]
Out[7]: -1

--

---
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.
Will | 29 Jul 10:44 2014
Picon

New-user question: Returning a struct with array member

Hello Cython Group, 

First off - I am really excited about Cython and so far working with Cython has been a lot of fun/rewarding.

Now for the new-user question -- I'm in the process of creating python bindings (wrapping) an existing C library. I've had success wrapping most of the library with Cython, however I am getting stuck with one struct that has two arrays as members. I've read through the documentation and have been searching through the forum, but am a bit stuck trying to figure out the best way to proceed. 

Snippet of the .h file for the original struct:
struct Paint {
float xform[6];
float extent[2];
float rad;
float f;
color color1;
color color2;
int img;
int repeat;
};
typedef struct Paint Paint;

Snippet of my .pxd file for the struct looks like this:
cdef extern from "graphicslib.h":
ctypedef struct Paint:
   float xform[6]
   float extent[2]
   float rad
   float f
   Color color1
   Color color2
   int img
   int repeat

And an example of a toy function in a .pyx file that attempts to return the struct (Note: glib.Color is another struct that contains four floats - r,g,b,a -- this part works just fine and returns a dict as expected :)
cimport cgraphicslib as glib

def paint(xform, extent, float rad, float f, color1, color2, int img, int repeat):
    cdef glib.Paint p
    cdef glib.Color c_color1 = color1
    cdef glib.Color c_color2 = color2
    cdef float c_xform[6] 
    cdef float c_extent[2] 
    
    for i in range(6):
        c_xform[i] = xform[i]

    for i in range(2):
        c_extent[i] = extent[i]

    p = glib.Paint(c_xform, c_extent, rad, f, c_color1, c_color2, img, repeat)
    return p

Building gives me the error: Cannot convert 'Paint' to Python object

If I omit the two arrays from the .pxd and .pyx - I am able to successfully build. If I return any of the other attributes of the struct, like color1, color2, rad, or img with syntax like return p.color1 I am also able to successfully. However, just trying to return the struct results in the above error. 

I would like to know how to properly return a struct that contains array members. Or, perhaps there is a more clever (Pythonic/Cythonic?) way of going about this. I have also tried using numpy nd.arrays as seen in multiple examples, but that somehow seems like overkill for such small static arrays.  

I would appreciate any tips/pointers. Thanks!  
_w

--

---
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