Merge pull request #66 from normanjaeckel/Version_String

New version string, fixes for the manage.py and update INSTALL
This commit is contained in:
Oskar Hahn 2012-12-01 06:18:01 -08:00
commit cf360de5fa
7 changed files with 78 additions and 80 deletions

View File

@ -6,7 +6,7 @@ Content
I. Installation on GNU/Linux and MacOSX using the Python Package Index (PyPI) I. Installation on GNU/Linux and MacOSX using the Python Package Index (PyPI)
II. Installation on GNU/Linux and MacOSX using the sources II. Installation on GNU/Linux and MacOSX using the sources
III. Installation on Windows (32/64bit) III. Installation on Windows (32bit) using the Python Package Index (PyPI)
If you need help ask on OpenSlides users mailing list. If you need help ask on OpenSlides users mailing list.
See http://openslides.org for more information. See http://openslides.org for more information.
@ -17,14 +17,15 @@ I. Installation on GNU/Linux and MacOSX using the Python Package Index (PyPI)
1. Check requirements: 1. Check requirements:
Make sure that you have installed Python (>= 2.5) on your system. Make sure that you have installed Python Programming Language 2
(>= 2.5) on your system.
2. Set up virtual environment with virtualenv (optional): 2. Setup a virtual environment with virtualenv (optional):
You can setup a virtual environment to install OpenSlides as You can setup a virtual environment to install OpenSlides as
non-root user. non-root user.
E. g. for ubuntu run: E. g. for Ubuntu run:
$ sudo apt-get install python-virtualenv $ sudo apt-get install python-virtualenv
To setup and activate the virtual environment, create your To setup and activate the virtual environment, create your
@ -69,7 +70,7 @@ II. Installation on GNU/Linux and MacOSX using the sources
+ ReportLab Toolkit + ReportLab Toolkit
+ Python Imaging Library (PIL) + Python Imaging Library (PIL)
E. g. for ubuntu run: E. g. for Ubuntu run:
$ sudo apt-get install python python-virtualenv python-reportlab python-imaging $ sudo apt-get install python python-virtualenv python-reportlab python-imaging
2. Get OpenSlides: 2. Get OpenSlides:
@ -82,11 +83,11 @@ II. Installation on GNU/Linux and MacOSX using the sources
https://github.com/OpenSlides/OpenSlides. This requires Git, https://github.com/OpenSlides/OpenSlides. This requires Git,
see http://git-scm.com/. see http://git-scm.com/.
E. g. for ubuntu run: E. g. for Ubuntu run:
$ sudo apt-get install git $ sudo apt-get install git
$ git clone git://github.com/OpenSlides/OpenSlides.git OpenSlides $ git clone git://github.com/OpenSlides/OpenSlides.git OpenSlides
3. Setup your virtual environment with virtualenv: 3. Setup a virtual environment with virtualenv:
Go to the (extracted/cloned) root directory of OpenSlides Go to the (extracted/cloned) root directory of OpenSlides
and create virtualenv environment: and create virtualenv environment:
@ -129,24 +130,19 @@ II. Installation on GNU/Linux and MacOSX using the sources
virtual environment (see 4.) before starting the server (see 6.). virtual environment (see 4.) before starting the server (see 6.).
III. Installation on Windows (32/64bit) III. Installation on Windows (32bit) using the Python Package Index (PyPI)
--------------------------------------- --------------------------------------------------------------------------
NOTE: There is a portable version of OpenSlides for Windows which does not NOTE: There is a portable version of OpenSlides for Windows which does not
required any install steps! If there is a reason that you can not use the required any install steps! If there is a reason that you can not use the
portable version you should run the following install steps. portable version you should run the following install steps.
1. Install requirements: 1. Install requirements:
OpenSlides requires following programs, which should be The OpenSlides install requires following programs, which should be
installed first: installed first:
+ Python Programming Language 2 (>= 2.5), + Python Programming Language 2 (>= 2.5)
+ Setuptools + Setuptools
+ ReportLab Toolkit
+ Python Imaging Library (PIL)
+ Django
+ django-mptt
a) Download and run 32bit MSI installer from http://www.python.org/: a) Download and run 32bit MSI installer from http://www.python.org/:
@ -163,33 +159,17 @@ portable version you should run the following install steps.
http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe
d) Install ReportLab Toolkit, Python Imaging Library (PIL), Django 2. Install OpenSlides:
and django-mptt:
Open command line (cmd) and run: Open command line (cmd) and run:
easy_install django django-mptt reportlab pil easy_install openslides
If you use a 64bit version of Python, you have to install reportlab
and PIL manually - without using easy_install.
2. Get OpenSlides:
a) Download latest OpenSlides release from http://openslides.org.
OR
b) Clone development version from OpenSlides' github repository
https://github.com/OpenSlides/OpenSlides. This requires Git,
see http://git-scm.com/.
Open command line (cmd) and run:
git clone git://github.com/OpenSlides/OpenSlides.git
3. Start OpenSlides server and open URL in your default browser: 3. Start OpenSlides server and open URL in your default browser:
python start.py Open command line (cmd) and run:
openslides
If you run this script the first time a new database and the If you run this script the first time a new database and the
admin account are created. Please change the password after admin account are created. Please change the password after
@ -198,4 +178,4 @@ portable version you should run the following install steps.
Username: admin Username: admin
Password: admin Password: admin
Use 'python start.py --help' to show all start options. Use 'openslides --help' to show all start options.

View File

@ -8,9 +8,10 @@
""" """
import os, sys import os, sys
from django.core.management import execute_from_command_line
from openslides.main import get_user_config_path, setup_django_environment
if __name__ == "__main__": if __name__ == "__main__":
sys.path.append(os.path.join(os.path.expanduser('~'), '.config', 'openslides')) setup_django_environment(
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") get_user_config_path('openslides', 'settings.py'))
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)

View File

@ -5,39 +5,47 @@
:license: GNU GPL, see LICENSE for more details. :license: GNU GPL, see LICENSE for more details.
""" """
VERSION = (1, 3, 0, 'rc', 1) VERSION = (1, 3, 0, 'final', 0) # During development it is the next release
RELEASE = False
def get_version(version=None): def get_version(version=None, release=None):
""" """
Derives a PEP386-compliant version number from VERSION. Adds id of Derives a PEP386-compliant version number from VERSION. Adds id of
the current git commit. the current git commit.
""" """
if version is None: if version is None:
version = VERSION version = VERSION
if release is None:
release = RELEASE
assert len(version) == 5 assert len(version) == 5
assert version[3] in ('dev', 'alpha', 'beta', 'rc', 'final') assert version[3] in ('alpha', 'beta', 'rc', 'final')
# Now build the two parts of the version number: # Now build the two parts of the version number:
# main = X.Y[.Z] # main = X.Y[.Z]
# sub = {a|b|c}N for alpha, beta and rc releases # sub = {a|b|c}N for alpha, beta and rc releases
# git's commit id is added # Add '-dev', if it is not a release commit
main_parts = 2 if version[2] == 0 else 3 main_parts = 2 if version[2] == 0 else 3
main = '.'.join(str(x) for x in version[:main_parts]) main = '.'.join(str(x) for x in version[:main_parts])
if version[3] != 'final': if version[3] != 'final':
if version[3] == 'dev': mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
try: sub = mapping[version[3]] + str(version[4])
import os
git_head_path = '.git/' + open('.git/HEAD', 'r').read()[5:].rstrip()
git_commit_id = open(os.path.abspath(git_head_path), 'r').read().rstrip()
except IOError:
git_commit_id = 'unknown'
sub = '-%s%s' % (version[3], git_commit_id)
else:
sub = '-' + version[3] + str(version[4])
else: else:
sub = '' sub = ''
if not release:
sub += '-dev'
return main + sub return main + sub
def get_git_commit_id():
"""
Catches the commit id of the git head.
"""
try:
git_head = open('.git/HEAD', 'r').read().rstrip()
if git_head[:5] == 'ref: ':
git_commit_id = open('.git/%s' % git_head[5:], 'r').read().rstrip()
else:
git_commit_id = git_head
except IOError:
git_commit_id = 'unknown'
return str(git_commit_id)

View File

@ -16,7 +16,7 @@ from django.core.urlresolvers import reverse
from django.utils.importlib import import_module from django.utils.importlib import import_module
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from openslides import get_version from openslides import get_version, get_git_commit_id, RELEASE
from openslides.utils.template import Tab from openslides.utils.template import Tab
from openslides.utils.views import FormView, TemplateView from openslides.utils.views import FormView, TemplateView
from .forms import GeneralConfigForm from .forms import GeneralConfigForm
@ -79,7 +79,14 @@ class VersionConfig(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(VersionConfig, self).get_context_data(**kwargs) context = super(VersionConfig, self).get_context_data(**kwargs)
context['versions'] = [('OpenSlides', get_version())]
# OpenSlides version. During development the git commit id is added.
openslides_version_string = get_version()
if not RELEASE:
openslides_version_string += ' Commit: %s' % get_git_commit_id()
context['versions'] = [('OpenSlides', openslides_version_string)]
# Version of plugins.
for plugin in settings.INSTALLED_PLUGINS: for plugin in settings.INSTALLED_PLUGINS:
try: try:
mod = import_module(plugin) mod = import_module(plugin)
@ -90,7 +97,6 @@ class VersionConfig(TemplateView):
plugin_name = mod.NAME plugin_name = mod.NAME
except AttributeError: except AttributeError:
plugin_name = mod.__name__.split('.')[0] plugin_name = mod.__name__.split('.')[0]
context['versions'].append((plugin_name, plugin_version)) context['versions'].append((plugin_name, plugin_version))
return context return context

View File

@ -129,7 +129,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request', 'django.core.context_processors.request',
'django.core.context_processors.i18n', 'django.core.context_processors.i18n',
'django.core.context_processors.static', 'django.core.context_processors.static',
'openslides.utils.utils.revision',
'openslides.utils.auth.anonymous_context_additions', 'openslides.utils.auth.anonymous_context_additions',
) )

View File

@ -29,12 +29,6 @@ from django.utils.translation import ugettext as _, ugettext_lazy
from openslides.utils.signals import template_manipulation from openslides.utils.signals import template_manipulation
from openslides import get_version
def revision(request):
return {'openslides_version': get_version()}
def gen_confirm_form(request, message, url): def gen_confirm_form(request, message, url):
""" """

View File

@ -9,15 +9,25 @@
from django.test import TestCase from django.test import TestCase
from openslides import get_version from openslides import get_version, get_git_commit_id
class InitTest(TestCase): class InitTest(TestCase):
def test_get_version(self): def test_get_version(self):
self.assertEqual(get_version((1, 3, 0, 'beta', 2)), '1.3-beta2') """
self.assertEqual(get_version((1, 0, 0, 'final', 0)), '1.0') Tests the method during development process and for releases.
self.assertEqual(get_version((2, 5, 3, 'alpha', 0)), '2.5.3-alpha0') """
git_version = get_version((2, 5, 0, 'dev', 0)) self.assertEqual(get_version(version=(1, 3, 0, 'beta', 2), release=False), '1.3b2-dev')
if 'unknown' in git_version: self.assertEqual(get_version(version=(1, 0, 0, 'final', 0), release=False), '1.0-dev')
self.assertEqual(len(git_version), 14) self.assertEqual(get_version(version=(2, 5, 3, 'alpha', 0), release=False), '2.5.3a0-dev')
else: self.assertEqual(get_version(version=(1, 3, 0, 'beta', 2), release=True), '1.3b2')
self.assertEqual(len(git_version), 47) self.assertEqual(get_version(version=(1, 0, 0, 'final', 0), release=True), '1.0')
self.assertEqual(get_version(version=(2, 5, 3, 'alpha', 0), release=True), '2.5.3a0')
self.assertEqual(get_version(version=(2, 5, 3, 'final', 0), release=True), '2.5.3')
def test_get_git_commit_id(self):
"""
Tests the lenght of the git commit id.
"""
git_commit_id = get_git_commit_id()
if not git_commit_id == 'unknown':
self.assertEqual(len(git_commit_id), 40)