[Pyrex] Pyrex importing question.

Blake Winton bwinton at latte.ca
Mon Nov 15 16:58:26 CET 2004


Greg Ewing wrote:
> Blake Winton wrote:
>> This leads me to believe that the
>> "import conduit.ConduitImpl" line is failing, but I
 >> don't know of any particularly good way to find out
 >> how or why.
> Are you importing the Pyrex module in the normal way
> from Python code (or another Pyrex module), or are you
> doing something tricky like loading and calling it
> directly from C code? If the latter, you're into
> unsupported territory, and I can't guarantee what
> will happen.

Naturally, I'm doing tricky things.  (Why do I always end up doing 
tricky things as my first introduction to something new?)

I am following the instructions on the page:
http://www.freenet.org.nz/python/embeddingpyrex/

> In particular, if the Pyrex module's init function
> doesn't get called, access to builtins (including
> __import__) won't work. Normally it gets called
> automatically when the module is imported, but if
> you're bypassing the import mechanism somehow, you
> may need to call it manually.

I am, indeed, calling initbtest manually.
------
long OpenConduit(PROGRESSFN __pyx_v_pFn,struct CCSyncProperties 
(*__pyx_v_rProps)) {
[snip...]

   /* "V:\Personal\svn\pEdit\conduit\btest.pyx":91 */
   Py_Initialize();

   /* "V:\Personal\svn\pEdit\conduit\btest.pyx":92 */
   initbtest();
------

> But in any case, even if this solves your import
> problem, if the cause is what I suggested (i.e.
> the init function not being called) then you are
> likely to have other problems as well.

So, given that I am calling initbtest, do you have any other ideas of 
what it might be?  As a side question, if I add debugging printfs to the 
generated C code, will it be overwritten by pyrex if the timestamp on 
the generated code is newer than the timestamp on the .pyx?  (Sheesh, it 
would probably have taken me less time to just try it than to ask.  So I 
tried it, and yeah, it doesn't re-generate the C-source.)

Thanks,
Blake.




More information about the Pyrex mailing list