SimTk/openmm — pull request #89 by rmcgibbo (2013-08-01 23:26:24+00:00)
Title: create a simtk.openmm.version module that contains the git revision

`mm.Platform.getOpenMMVersion()` is a useful function, but I think there's some demand for version info at the python API level, including the git revision.

This PR does the following:
1) cmake tries to run `git rev-parse HEAD` inside the source directory, and writes the results to a file in the python staging directory as `version.py`.
2) python setup.py reads the git_revision, and writes a "full featured" `version.py` module containg the git revision as well as the version info that's already declared inside the setup.py file and used by distutils (`MAJOR_VERSION_NUM`, `MINOR_VERSION_NUM`, `BUILD_INFO`)

```
rmcgibbo@vspm9 ~/local/openmm.build [latest]
$ cat python/simtk/openmm/version.py

# THIS FILE IS GENERATED FROM OPENMM SETUP.PY
short_version = '5.1.0'
version = '5.1.0'
full_version = '5.1.0.dev-52c444c'
git_revision = '52c444c579f03523eaf274ccfa03b96fbd009909'
release = False

if not release:
version = full_version
```

The form of the final `version.py` is the same as what's available for [numpy](https://github.com/numpy/numpy/blob/master/setup.py#L103). The only reason this code is slightly trickier is that you can't run `git rev-parse HEAD` in the directory from which you run `python setup.py`, since cmake uses a separate build directory.