libgeos version detection fixes

Backports changes to libgeos detection to make this django work with newer builds of the geos library (homebrew builds of geos, for example, has a revision tag, which in this version of django fails).