summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-09 01:30:19 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-09 01:30:19 +0200
commite0e628ec54b8a4d7f41f86f9f535d791a437b13c (patch)
tree1bc7a3f7546071afb6dd354d46eeb39c53c28f13
parentf0d7e336f73a188405995b41aa30caaa78a01faa (diff)
downloadfactory-boy-e0e628ec54b8a4d7f41f86f9f535d791a437b13c.tar
factory-boy-e0e628ec54b8a4d7f41f86f9f535d791a437b13c.tar.gz
Better version computing code.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
-rw-r--r--docs/conf.py19
-rwxr-xr-xsetup.py18
2 files changed, 32 insertions, 5 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 9986b45..fd9ded6 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -48,10 +48,23 @@ copyright = u'2011, Raphaël Barrois, Mark Sandstrom'
# |version| and |release|, also used in various other places throughout the
# built documents.
#
-# The short X.Y version.
-version = '1.1'
+root = os.path.abspath(os.path.dirname(__file__))
+def get_version(*module_dir_components):
+ import re
+ version_re = re.compile(r"^__version__ = ['\"](.*)['\"]$")
+ module_root = os.path.join(root, os.pardir, *module_dir_components)
+ module_init = os.path.join(module_root, '__init__.py')
+ with open(module_init, 'r') as f:
+ for line in f:
+ match = version_re.match(line[:-1])
+ if match:
+ return match.groups()[0]
+ return '0.1.0'
+
# The full version, including alpha/beta/rc tags.
-release = '1.1.5'
+release = get_version('factory')
+# The short X.Y version.
+version = '.'.join(release.split('.')[:2])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/setup.py b/setup.py
index ace4473..9bff8d1 100755
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+import os
+import re
import sys
from distutils.core import setup
from distutils import cmd
-# Remember to change in factory/__init__.py as well!
-VERSION = '1.1.5'
+root = os.path.abspath(os.path.dirname(__file__))
+
+def get_version(*module_dir_components):
+ version_re = re.compile(r"^__version__ = ['\"](.*)['\"]$")
+ module_root = os.path.join(root, *module_dir_components)
+ module_init = os.path.join(module_root, '__init__.py')
+ with open(module_init, 'r') as f:
+ for line in f:
+ match = version_re.match(line[:-1])
+ if match:
+ return match.groups()[0]
+ return '0.1.0'
+
+VERSION = get_version('factory')
class test(cmd.Command):