recover version directory from CMakeLists.txt

this avoid mistakes caused by double declaration of the version
in CMakeLists.txt and conf.py
This commit is contained in:
kakwa 2016-09-12 19:33:31 +02:00
parent a6d73bfd49
commit f51c942f8e
1 changed files with 10 additions and 1 deletions

View File

@ -16,9 +16,18 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
import re
sys.path.insert(0, os.path.abspath('..'))
def get_version():
cmake = os.path.join(os.path.dirname(__file__),'../CMakeLists.txt')
with open(cmake) as f:
for line in f.readlines():
m = re.search('set\(VERSION ([\.0-9]+)\)', line)
if m:
return m.group(1)
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@ -50,7 +59,7 @@ copyright = u'2016, Pierre-Francois Carpentier'
#
# The short X.Y version.
# The full version, including alpha/beta/rc tags.
release = '0.0.2'
release = get_version()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.