From a7c6ff939291dc33463a17a6813d7772b00a9311 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Wed, 7 Aug 2013 01:07:31 -0700 Subject: [PATCH] Set version in setup.py docs automatically --- docs/conf.py | 14 +++++++++++--- model_utils/__init__.py | 2 ++ setup.py | 10 +++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 15eaebf..d79adff 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -43,14 +43,22 @@ master_doc = 'index' project = u'django-model-utils' copyright = u'2013, Carl Meyer' +parent_dir = os.path.dirname(os.path.dirname(__file__)) + +def get_version(): + with open(os.path.join(parent_dir, 'model_utils', '__init__.py')) as f: + for line in f: + if line.startswith('__version__ ='): + return line.split('=')[1].strip().strip('"\'') + # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = '1.4' # The full version, including alpha/beta/rc tags. -release = '1.4.0' +release = get_version() +# The short X.Y version. +version = release # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/model_utils/__init__.py b/model_utils/__init__.py index 731e9b7..36586ec 100644 --- a/model_utils/__init__.py +++ b/model_utils/__init__.py @@ -1,2 +1,4 @@ from .choices import Choices from .tracker import FieldTracker, ModelTracker + +__version__ = '1.4.0.post1' diff --git a/setup.py b/setup.py index 2405f90..a7ceb1c 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +from os.path import join from setuptools import setup, find_packages @@ -6,9 +7,16 @@ long_description = (open('README.rst').read() + open('TODO.rst').read()) +def get_version(): + with open(join('model_utils', '__init__.py')) as f: + for line in f: + if line.startswith('__version__ ='): + return line.split('=')[1].strip().strip('"\'') + + setup( name='django-model-utils', - version='1.4.0.post1', + version=get_version(), description='Django model mixins and utilities', long_description=long_description, author='Carl Meyer',