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...
martin@Martin-Laptop:~/test$ sage minimal.py
Error compiling Cython file:
------------------------------------------------------------
...
cdef del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash)
#This is for compatibility: this routine is available in Py3 and we
#implement it ourselves in Py2.
IF PY_VERSION_HEX<=0x02ffffff:
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/cpython/dict_del_by_value.pxd:9:3: Compile-time name 'PY_VERSION_HEX' not defined
Error compiling Cython file:
------------------------------------------------------------
...
#in the underlying dictionary, we have stored a KeyedRef r
#under a key k. The attribute r.key is the hash of k.
if D._guard_level:
D._pending_removals.append(r)
else:
del_dictitem_by_exact_value(<PyDictObject *>D, <PyObject *>r, r.key)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:213:12: undeclared name not builtin: del_dictitem_by_exact_value
Error compiling Cython file:
------------------------------------------------------------
...
#in the underlying dictionary, we have stored a KeyedRef r
#under a key k. The attribute r.key is the hash of k.
if D._guard_level:
D._pending_removals.append(r)
else:
del_dictitem_by_exact_value(<PyDictObject *>D, <PyObject *>r, r.key)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:213:41: 'PyDictObject' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
#in the underlying dictionary, we have stored a KeyedRef r
#under a key k. The attribute r.key is the hash of k.
if D._guard_level:
D._pending_removals.append(r)
else:
del_dictitem_by_exact_value(<PyDictObject *>D, <PyObject *>r, r.key)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:213:59: Cannot convert 'PyObject *' to Python object
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:466:28: undeclared name not builtin: PyDict_GetItemWithError
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:466:51: Cannot convert Python object to 'PyObject *'
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:466:13: Storing unsafe C derivative of temporary Python reference
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:578:51: Cannot convert Python object to 'PyObject *'
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:578:13: Storing unsafe C derivative of temporary Python reference
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject * wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:654:52: Cannot convert Python object to 'PyObject *'
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject * wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:654:13: Storing unsafe C derivative of temporary Python reference
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:694:51: Cannot convert Python object to 'PyObject *'
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:694:13: Storing unsafe C derivative of temporary Python reference
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:738:51: Cannot convert Python object to 'PyObject *'
Error compiling Cython file:
------------------------------------------------------------
...
Traceback (most recent call last):
...
TypeError: mutable matrices are unhashable
"""
cdef PyObject* wr = PyDict_GetItemWithError(self, k)
^
------------------------------------------------------------
/home/martin/sage-develop/local/lib/python2.7/site-packages/sage/misc/weak_dict.pyx:738:13: Storing unsafe C derivative of temporary Python reference
/home/martin/.pyxbld/temp.linux-x86_64-2.7/pyrex/sage/misc/weak_dict.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^~~~~
Traceback (most recent call last):
File "minimal.py", line 2, in <module>
from minimal_pyx import minimal_fun
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 458, in load_module
language_level=self.language_level)
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 233, in load_module
exec("raise exc, None, tb", {'exc': exc, 'tb': tb})
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 216, in load_module
mod = imp.load_dynamic(name, so_path)
File "minimal_pyx.pyx", line 1, in init minimal_pyx
from sage.misc.cachefunc import cached_method
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 458, in load_module
language_level=self.language_level)
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 233, in load_module
exec("raise exc, None, tb", {'exc': exc, 'tb': tb})
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 216, in load_module
mod = imp.load_dynamic(name, so_path)
File "weak_dict.pxd", line 1, in init sage.misc.cachefunc
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 458, in load_module
language_level=self.language_level)
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 233, in load_module
exec("raise exc, None, tb", {'exc': exc, 'tb': tb})
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 215, in load_module
inplace=build_inplace, language_level=language_level)
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 191, in build_module
reload_support=pyxargs.reload_support)
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "/home/martin/sage-develop/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/home/martin/sage-develop/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/martin/sage-develop/local/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/home/martin/sage-develop/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
self.build_extension(ext)
File "/home/martin/sage-develop/local/lib/python2.7/distutils/command/build_ext.py", line 499, in build_extension
depends=ext.depends)
File "/home/martin/sage-develop/local/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/martin/sage-develop/local/lib/python2.7/distutils/unixccompiler.py", line 126, in _compile
raise CompileError, msg
ImportError: Building module minimal_pyx failed: ['ImportError: Building module sage.misc.cachefunc failed: [\'ImportError: Building module sage.misc.weak_dict failed: ["CompileError: command \\\'gcc\\\' failed with exit status 1\\\\n"]\\n\']\n']