Extract mechanism for determining pex version so it can be used for cases other than client version.

Reviewed at https://reviews.apache.org/r/29058/