MAINT: change place where NPY_NO_DEPRECATED_API is defined in f2py.

This makes sure to undef at the end, and by putting the define in the
C code it ensures that the error message is understandable.
Merge pull request #5281 from rgommers/f2py-deprecated-api

MAINT: change place where NPY_NO_DEPRECATED_API is defined in f2py.