Problems building...

20 views
Skip to first unread message

Ray Van Dolson

unread,
Oct 17, 2010, 4:59:41 PM10/17/10
to pym...@googlegroups.com
Trying to build pymssql 1.9.908 on Fedora 13 with Cython 0.13 and
Python 2.6.4 and am getting the following errors when running python
setup.py build:

Error converting Pyrex file to C:
------------------------------------------------------------
...
self.params[name] = value

# Store the converted parameter in our parameter list so we can
# free() it later.
if data != NULL:
pn = <_mssql_parameter_node *>PyMem_Malloc(sizeof(_mssql_parameter_node))
^
------------------------------------------------------------

/home/rayvd/src/fedora/pymssql/f14/pymssql-1.9.908/_mssql.pyx:1103:54: undeclared name not builtin: PyMem_Malloc

(There are many more like this).

I'm not Cython expert, but anyone know where to start tracking this
down? I'll see if I can find where PyMem_Malloc should live, but
hopefully someone out there can point me in the right direction.

Thanks,
Ray

Ray Van Dolson

unread,
Oct 17, 2010, 5:56:53 PM10/17/10
to pym...@googlegroups.com

The following _almost_ fixes the problem:

--- pymssql-1.9.908/_mssql.pyx 2010-04-28 03:09:12.000000000 -0700
+++ pymssql-1.9.908.new/_mssql.pyx 2010-10-17 14:49:22.000000000 -0700
@@ -30,7 +30,7 @@
DEF PYMSSQL_MSGSIZE = (MSSQLDB_MSGSIZE * 8)
DEF EXCOMM = 9

-from python_version cimport PY_MAJOR_VERSION, PY_MINOR_VERSION
+from cpython cimport PY_MAJOR_VERSION, PY_MINOR_VERSION

if PY_MAJOR_VERSION >= 2 and PY_MINOR_VERSION >= 5:
import uuid
@@ -38,10 +38,10 @@
import decimal
import datetime
from sqlfront cimport *
-from stdio cimport fprintf, sprintf, FILE
-from stdlib cimport strlen, strcpy
-from python_mem cimport PyMem_Malloc, PyMem_Free
-from python_long cimport PY_LONG_LONG
+from libc.stdio cimport fprintf, sprintf, FILE
+from libc.string cimport strlen, strcpy
+from cpython cimport PyMem_Malloc, PyMem_Free
+from cpython cimport PY_LONG_LONG

cdef extern from "stdio.h" nogil:
cdef FILE *stderr

However, I still get the following:

running build
running build_ext
cythoning _mssql.pyx to _mssql.c

Error converting Pyrex file to C:
------------------------------------------------------------
...

if strlen(self._charset) > 0 and type(value) is unicode:
value = value.encode(self._charset)

strValue = <char *>PyMem_Malloc(len(value) + 1)
strcpy(strValue, value)
^
------------------------------------------------------------

/home/rayvd/src/fedora/pymssql/f14/pymssql-1.9.908/_mssql.pyx:650:34: Cannot convert Python object to 'const_char *'
building '_mssql' extension

The code in setup.py this is complaining about appears to make every
effort to ensure that "value" is a string, so I'm not sure why strcpy
is mad.

Maybe a question for the Cython folks.

Ray

Reply all
Reply to author
Forward
0 new messages