|
43 | 43 | project = u'python-bioformats' |
44 | 44 | copyright = u'2014, Broad Institute of MIT and Harvard' |
45 | 45 |
|
| 46 | +def get_version(): |
| 47 | + version_file = os.path.join(os.path.dirname(__file__), '..', 'bioformats', |
| 48 | + '_version.py') |
| 49 | + if os.path.exists(version_file): |
| 50 | + with open(version_file) as f: |
| 51 | + cached_version_line = f.read().strip() |
| 52 | + try: |
| 53 | + import re |
| 54 | + # From http://stackoverflow.com/a/3619714/17498 |
| 55 | + cached_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", |
| 56 | + cached_version_line, re.M).group(1) |
| 57 | + except: |
| 58 | + raise RuntimeError("Unable to find version in %s" % version_file) |
| 59 | + split_version = cached_version.split('.') |
| 60 | + return '.'.join(split_version[:2]), cached_version |
| 61 | + else: |
| 62 | + return '0.0', '0.0.0' |
| 63 | + |
46 | 64 | # The version info for the project you're documenting, acts as replacement for |
47 | 65 | # |version| and |release|, also used in various other places throughout the |
48 | 66 | # built documents. |
49 | 67 | # |
50 | | -# The short X.Y version. |
51 | | -version = '1.0' |
52 | | -# The full version, including alpha/beta/rc tags. |
53 | | -release = '1.0.0pr3' |
| 68 | +# version: The short X.Y version. |
| 69 | +# release: The full version, including alpha/beta/rc tags. |
| 70 | +version, release = get_version() |
54 | 71 |
|
55 | 72 | # The language for content autogenerated by Sphinx. Refer to documentation |
56 | 73 | # for a list of supported languages. |
|
0 commit comments