I don't know why you need it, but this sounds like the wrong solution to your problem. However:
__pyx_f isn't a single filename but an array of filenames - Cython source code can come from a number of places (a pyx file, a pxd file, a file that's been included in another, utility code that Cython itself generates). As far as I can tell __pyx_f is only used for generating tracebacks and thus which element is picked depends on where the traceback comes from. I don't know how or if they are ordered.
You could access it by modifying the source code of your Cython file. I would probably declare it as an extern variable:
cdef extern from *:
const char* __pyx_f[]
You can then create a Cython function to access the variable:
def get_from_pyx_f(n):
return __pyx_f[n]
I don't think there's any way of telling how big the array is so this risks a segmentation fault if you try to access too far. None of this is tested so it may need small modifications to work.
Alternatively you could write a function that generates a traceback and then extract the file name from that.