IMHO, "from ... (c)import *" has the same code smell in Cython code that it
has in Python.
From the snippet you posted, I can't see a reason why this should fail.
Could you provide a link to the complete code file(s) so that others can
try to reproduce this?
> Oh one more thing. It really is trying to create a .cpp file and not
> a .c file despite the Error converting Pyrex file to C, since
> the .cpp file exists but the .c file does not.
Yes, that message dates back to the old days when C++ code generation
wasn't a common thing in Pyrex, long before Cython even existed.
Stefan
And it smells so bad that Cython could emit warnings for the cimport
case, where a name clash occurs. What do you think?
--
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
Import vs. cimport is a known source of oddness, and we're looking into this.
> Am I doing something wrong here, or is this a bug? I do note that it
> works most everywhere else I've ported it.
I just tried
from gpumat cimport *
cimport numpy as np
import numpy as np
import pylab
import sys
def foo(xords, garr):
pylab.plot(xords, abs(garr))
and was not able to reproduce your error. Are you sure the Cython on
that machine is up to date?
- Robert
seventhunders, 15.10.2010 19:10:
>>> This particular error seems to crop up when trying to import certain
>>> python modules within cython. Moreover the behavior varies from
>>> platform to platform. I have a cython module that compiles and runs
>>> perfectly on windows xp, windows 7 64 bit, archlinux 64 and a bunch
>>> of fedora versions but fails miserably on xubunu 9.10
>
> Unfortunately I can't release the entire code
> since it's proprietary and to make matters
> worse it only seems to occur for this particular setup.
In that case, why do you bother with running Cython on that system at all?
I'd be a lot more comfortable with shipping well tested C sources for the
build, instead of letting users run their own version of Cython on it,
which may or may not generate reproducible code.
> Could it be something in python that causes this?
Not impossible. I assume you want to imply that it's not the same Python
version on all installations?
Stefan
What happens if you add a line with "global pylab" before the offending line?
I have no idea. The cythonization process should be very consistant
from platform to platform (much more so than the C compilation). Does
the following at least compile for you?
- Robert
----------------------------------------
Yes, that error is very strange indeed. I know it sounds trivial, but
I would be sure to double-check that you're actually compiling the
code and using the software versions that you think you are. And
if/when you do find a bug, please let us know.
Distutils invokes Cython programatically, not via the command line.
It's all in Cython/Distutils/... What cython is your command line
"cython" getting? Also, I would make sure there's not an issue with
gpumat.pxd vs. pygpumat.pyx vs. naming the module gpumat.
- Robert
Yes. It looks like you're passing a whole lot of options to the
distutils command that you're not even mentioning on the command line.
You shouldn't have to, unless you're assigning to it somewhere in the
body. (Note that "import pylab" is an assignment.)
> I probably ought to take your simple example and
> make it a method of an extension
> class to see if the behavior can be duplicated in a simpler example.
Yes, it's hard to even guess what the problem is without a
reproducible example.
I wasn't able to reproduce this, perhaps because I only have part of
the source?
> Also there are definite differences between the command line
> invocation of cython and
> the progammatic one.
You're passing them different options.