bugfix in build_ext: check that ext has an attribute before trying to us it

Small fix, but it was noted as a bug here http://chess.eecs.berkeley.edu/ptexternal/wiki/Main/JModelica and I encountered it while trying to install scipy.  There may be a more sensible way to deal with this problem, but this hack is effective.