From 5108a720f2e36657cd6d8dfe1fbf1f7af11a999d Mon Sep 17 00:00:00 2001 From: benoitc Date: Sat, 31 Jul 2010 16:18:13 +0200 Subject: [PATCH] use a specific release number for dev depending on git tag --- gunicorn/__init__.py | 21 ++++++++++++++++++++- gunicorn/util.py | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gunicorn/__init__.py b/gunicorn/__init__.py index 8628dc0f..abb29389 100644 --- a/gunicorn/__init__.py +++ b/gunicorn/__init__.py @@ -3,5 +3,24 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -version_info = (0, 10, 0) + +import os + +if os.environ.get('release') != "true": + + minor_tag = "-dev" + try: + from gunicorn.util import popen3 + + stdin, stdout, stderr = popen3("git rev-parse --short HEAD --") + error = stderr.read() + if not error: + minor_tag = ".%s-git" % stdout.read() + except OSError: + pass +else: + minor_tag = "" + + +version_info = (0, 10, "1%s" % minor_tag) __version__ = ".".join(map(str, version_info)) diff --git a/gunicorn/util.py b/gunicorn/util.py index deedaf4c..1ba39a3a 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -14,6 +14,22 @@ import sys import textwrap import time +try:#python 2.6, use subprocess + import subprocess + subprocess.Popen # trigger ImportError early + closefds = os.name == 'posix' + + def popen3(cmd, mode='t', bufsize=0): + p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + close_fds=closefds) + p.wait() + return (p.stdin, p.stdout, p.stderr) +except ImportError: + subprocess = None + popen3 = os.popen3 + + MAXFD = 1024 if (hasattr(os, "devnull")): REDIRECT_TO = os.devnull