Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

version: Do not write builtin_version.py

Simply update the _default_version variable when creating new
releases instead of having all of the extra code for parsing the
version from git.  This removes a lot of complexity.

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information...
commit 00670d1ee90718587149547a1606c48f5eeb219c 1 parent be8baf9
@davvid davvid authored
Showing with 40 additions and 122 deletions.
  1. +0 −1  Makefile
  2. +2 −73 cola/version.py
  3. +37 −47 setup.py
  4. +1 −1  share/doc/git-cola/conf.py
View
1  Makefile
@@ -87,7 +87,6 @@ clean:
find . -name '*.py[co]' -print0 | xargs -0 rm -f
rm -rf build dist tmp tags git-cola.app
rm -rf share/locale
- rm -f cola/builtin_version.py*
tags:
find . -name '*.py' -print0 | xargs -0 ctags -f tags
View
75 cola/version.py
@@ -12,7 +12,6 @@
srcdir = os.path.dirname(os.path.dirname(__file__))
sys.path.insert(1, srcdir)
-from cola import utils
from cola.git import git
from cola.decorators import memoize
@@ -34,78 +33,8 @@ def get(key):
return _versions.get(key)
-class VersionUnavailable(Exception):
- pass
-
-
-def git_describe_version():
- """Inspect the cola git repository and return the current version."""
- if not os.path.isdir('.git') or not os.path.exists('cola/__init__.py'):
- raise VersionUnavailable('not a git-cola sandbox')
-
- v = git.execute(['git', 'describe', '--match=v[0-9]*', '--abbrev=7'])
- if v:
- return utils.strip_prefix('v', v.replace('-', '.'))
- else:
- raise VersionUnavailable('bad version: "%s"' % v)
-
-
-def builtin_version():
- """Return the builtin version or throw a VersionUnavailable exception"""
- try:
- from cola import builtin_version as bv
- except ImportError:
- raise VersionUnavailable()
- else:
- return bv.version
-
-
-@memoize
-def _builtin_version_file(ext='py'):
- """Returns the path to cola's builtin_version.py."""
- dirname = os.path.dirname(__file__)
- return os.path.join(dirname, 'builtin_version.%s' % ext)
-
-
-def release_version():
- """Return a version number for a release
-
- First see if there is a version file (included in release tarballs),
- then try git-describe, then default.
-
- """
- try:
- return git_describe_version()
- except VersionUnavailable:
- return version()
-
-
-def write_builtin_version():
- """Writes cola/builtin_version.py
-
- """
- v = release_version()
- f = file(_builtin_version_file(), 'w')
- f.write('# This file was generated automatically. Do not edit by hand.\n'
- 'version = %r\n' % v)
- f.close()
-
-
-def delete_builtin_version():
- """Deletes cola/builtin_version.py."""
- for ext in ('py', 'pyc', 'pyo'):
- fn = _builtin_version_file(ext=ext)
- if os.path.exists(fn):
- os.remove(fn)
-
-
def version():
- """Returns the builtin version or calculates the current version."""
- for v in [builtin_version, git_describe_version]:
- try:
- return v()
- except VersionUnavailable:
- continue
+ """Returns the current version"""
return _default_version
@@ -144,4 +73,4 @@ def git_version():
if __name__ == '__main__':
- print(release_version())
+ print(version())
View
84 setup.py
@@ -14,19 +14,22 @@
def main():
- # ensure readable files
- old_mask = os.umask(0022)
-
_check_python_version()
_setup_environment()
_check_git_version()
_check_pyqt_version()
+ _run_setup()
- version.write_builtin_version()
- _run_setup()
- # restore the old mask
- os.umask(old_mask)
+def _check_python_version():
+ """Check the minimum Python version
+ """
+ pyver = platform.python_version()
+ if not version.check('python', pyver):
+ print >> sys.stderr, ('Python version %s or newer required. '
+ 'Found %s' % (version.get('python'), pyver))
+ sys.exit(1)
+
def _setup_environment():
"""Adds win32/ to our path for windows only"""
@@ -36,6 +39,33 @@ def _setup_environment():
win32 = os.path.join(srcdir, 'win32')
os.environ['PATH'] = win32 + os.pathsep + path
+
+def _check_git_version():
+ """Check the minimum GIT version
+ """
+ git_version = version.git_version()
+ if not version.check('git', git_version):
+ print >> sys.stderr, ('GIT version %s or newer required. '
+ 'Found %s' % (version.get('git'), git_version))
+ sys.exit(1)
+
+
+def _check_pyqt_version():
+ """Check the minimum PyQt version
+ """
+ pyqtver = 'None'
+ try:
+ from PyQt4 import QtCore
+ pyqtver = QtCore.PYQT_VERSION_STR
+ if version.check('pyqt', pyqtver):
+ return
+ except ImportError:
+ pass
+ print >> sys.stderr, ('PyQt4 version %s or newer required. '
+ 'Found %s' % (version.get('pyqt'), pyqtver))
+ sys.exit(1)
+
+
def _run_setup():
"""Runs distutils.setup()"""
@@ -51,9 +81,6 @@ def _run_setup():
'win32/py2exe-setup.py',
'win32/py2exe-setup.cmd',
])
- requires = []
- else:
- requires = ['simplejson']
setup(name = 'git-cola',
version = version.version(),
@@ -63,7 +90,6 @@ def _run_setup():
author_email = 'git-cola@googlegroups.com',
url = 'http://git-cola.github.com/',
long_description = 'A sleek and powerful git GUI',
- requires = requires,
scripts = scripts,
cmdclass = cmdclass,
data_files = cola_data_files())
@@ -111,41 +137,5 @@ def _app_path(dirname, entry):
return (dirname, glob(os.path.join(dirname, entry)))
-def _check_python_version():
- """Check the minimum Python version
- """
- pyver = platform.python_version()
- if not version.check('python', pyver):
- print >> sys.stderr, ('Python version %s or newer required. '
- 'Found %s' % (version.get('python'), pyver))
- sys.exit(1)
-
-
-def _check_git_version():
- """Check the minimum GIT version
- """
- git_version = version.git_version()
- if not version.check('git', git_version):
- print >> sys.stderr, ('GIT version %s or newer required. '
- 'Found %s' % (version.get('git'), git_version))
- sys.exit(1)
-
-
-def _check_pyqt_version():
- """Check the minimum PyQt version
- """
- pyqtver = 'None'
- try:
- from PyQt4 import QtCore
- pyqtver = QtCore.PYQT_VERSION_STR
- if version.check('pyqt', pyqtver):
- return
- except ImportError:
- pass
- print >> sys.stderr, ('PyQt4 version %s or newer required. '
- 'Found %s' % (version.get('pyqt'), pyqtver))
- sys.exit(1)
-
-
if __name__ == '__main__':
main()
View
2  share/doc/git-cola/conf.py
@@ -62,7 +62,7 @@
# The short X.Y version.
version = cola.version.version()
# The full version, including alpha/beta/rc tags.
-release = cola.version.release_version()
+release = cola.version.version()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Please sign in to comment.
Something went wrong with that request. Please try again.