summaryrefslogtreecommitdiff
path: root/django/__init__.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2012-04-29 13:44:32 -0500
committerAdrian Holovaty <adrian@holovaty.com>2012-04-29 13:44:32 -0500
commit5b644a5464e9612138dd7061abd386433bdc09f0 (patch)
treef0d092cf025b6ac4b3918d5161e7635aba98c4a9 /django/__init__.py
parente7d99aa0fee232e8dd2b9a15112a56f35cea4e9b (diff)
Moved version code out of __init__.py.
Moved everything except VERSION and a get_version() stub out of the top-level __init__.py, so that we're not importing all that stuff all the time. And because it's cleaner.
Diffstat (limited to 'django/__init__.py')
-rw-r--r--django/__init__.py56
1 files changed, 5 insertions, 51 deletions
diff --git a/django/__init__.py b/django/__init__.py
index 85cf02c9a4..32e1374765 100644
--- a/django/__init__.py
+++ b/django/__init__.py
@@ -1,53 +1,7 @@
-import datetime
-import os
-import subprocess
-
-
VERSION = (1, 5, 0, 'alpha', 0)
-
-def get_version(version=None):
- """Derives a PEP386-compliant version number from VERSION."""
- if version is None:
- version = VERSION
- assert len(version) == 5
- assert version[3] in ('alpha', 'beta', 'rc', 'final')
-
- # Now build the two parts of the version number:
- # main = X.Y[.Z]
- # sub = .devN - for pre-alpha releases
- # | {a|b|c}N - for alpha, beta and rc releases
-
- parts = 2 if version[2] == 0 else 3
- main = '.'.join(str(x) for x in version[:parts])
-
- sub = ''
- if version[3] == 'alpha' and version[4] == 0:
- git_changeset = get_git_changeset()
- if git_changeset:
- sub = '.dev%s' % git_changeset
-
- elif version[3] != 'final':
- mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
- sub = mapping[version[3]] + str(version[4])
-
- return main + sub
-
-
-def get_git_changeset():
- """Returns a numeric identifier of the latest git changeset.
-
- The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
- This value isn't guaranteed to be unique but collisions are very unlikely,
- so it's sufficient for generating the development version numbers.
- """
- repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- git_show = subprocess.Popen('git show --pretty=format:%ct --quiet HEAD',
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- shell=True, cwd=repo_dir, universal_newlines=True)
- timestamp = git_show.communicate()[0].partition('\n')[0]
- try:
- timestamp = datetime.datetime.utcfromtimestamp(int(timestamp))
- except ValueError:
- return None
- return timestamp.strftime('%Y%m%d%H%M%S')
+def get_version(*args, **kwargs):
+ # Don't litter django/__init__.py with all the get_version stuff.
+ # Only import if it's actually called.
+ from django.utils.version import get_version
+ return get_version(*args, **kwargs)