Thank you!  This gets me past the first problem.  Unfortunately, I now get 
further compilation errors, like

Building module sage.graphs.base.sparse_graph failed: ["CompileError: 
command 'gcc' failed with exit status 1\n"]

and

./.pyxbld_local/temp.linux-x86_64-2.7/pyrex/sage/modules/vector_real_double_dense.c:567:10:
 
fatal error: cython_metaclass.h: No such file or directory
 #include "cython_metaclass.h"
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

but it will take some time to create a minimal non-working example :-(

Thanks again,

Martin

Am Dienstag, 24. April 2018 07:13:24 UTC+2 schrieb Nils Bruin:
>
> On Monday, April 23, 2018 at 8:41:30 PM UTC-7, Martin R wrote:
>>
>> Hi there,
>>
>> Since 8.2.rc0 (the update to cython 0.28.1) I'm having trouble using 
>> pyximport.  Here is a minimal non working example:
>>
>> ######## minimal.py ############
>> import pyximport; pyximport.install();
>> from minimal_pyx import minimal_fun
>> ######## end minimal.py ############
>>
>> ######## minimal_pyx.pyx ############
>> from sage.misc.cachefunc        import cached_method
>>
>> def minimal_fun():
>>     print("hi")
>> ######## end minimal_pyx.pyx ############
>>
>> Running this with "sage minimal.py" fails as reproduced below.
>>
>> It seems that I should somehow set the compile_time_env variable 
>> 'PY_VERSION_HEX', and set it to sys.hexversion.  I don't know how to do 
>> that (especially not when using pyximport), and I'm puzzled because I would 
>> have thought that dict_del_by_value.pyx is already compiled...
>>
>> Thanks for any hints or workarounds!
>>
>> Martin
>>
>
> The problem seems to be that pyximport gets its hooks a little too deeply 
> into the import system (see the documentation: they warn that pyximport 
> only works in simple cases).
>
> In this case, it seems that "import sage.misc.cachefunc" tries to do a 
> little too much when the pyximport hook is active. A workaround is to make 
> sure it's imported before the hook is activated, i.e.,
>
> import sage.misc.cachefunc
> import pyximport; pyximport.install();
> from minimal_pyx import minimal_fun
>
> seems to do the trick.
>
> To cover all cases, perhaps try "import sage.all" before activating the 
> hook. That should get you into a state that's comparable to what you have 
> at the sage prompt. Quoting from the cython manual:
>
> This allows you to automatically run Cython on every .pyx that Python is 
>> trying to import. You should use this for simple Cython builds only where 
>> no extra C libraries and no special building setup is needed.
>>
>
> ostensibly, sage doesn't qualify; so I think it's not a bug that you need 
> a workaround.
>

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

Reply via email to