diff --git a/INSTALL.txt b/INSTALL.txt index 8a4cdad95..076e088c0 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -6,7 +6,7 @@ Content I. Installation on GNU/Linux and MacOSX using the Python Package Index (PyPI) 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. 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: - 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 non-root user. - E. g. for ubuntu run: + E. g. for Ubuntu run: $ sudo apt-get install python-virtualenv 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 + 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 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, see http://git-scm.com/. - E. g. for ubuntu run: + E. g. for Ubuntu run: $ sudo apt-get install git $ 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 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.). -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 -required any install steps! If there is a reason that you can not use the +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 portable version you should run the following install steps. - 1. Install requirements: - OpenSlides requires following programs, which should be + The OpenSlides install requires following programs, which should be installed first: - + Python Programming Language 2 (>= 2.5), + + Python Programming Language 2 (>= 2.5) + Setuptools - + ReportLab Toolkit - + Python Imaging Library (PIL) - + Django - + django-mptt 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 - d) Install ReportLab Toolkit, Python Imaging Library (PIL), Django - and django-mptt: + 2. Install OpenSlides: Open command line (cmd) and run: - easy_install django django-mptt reportlab pil - - 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 + easy_install openslides 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 admin account are created. Please change the password after @@ -198,4 +178,4 @@ portable version you should run the following install steps. Username: admin Password: admin - Use 'python start.py --help' to show all start options. + Use 'openslides --help' to show all start options. diff --git a/manage.py b/manage.py index 5ddfd35aa..af82b6f37 100644 --- a/manage.py +++ b/manage.py @@ -8,9 +8,10 @@ """ 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__": - sys.path.append(os.path.join(os.path.expanduser('~'), '.config', 'openslides')) - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") - from django.core.management import execute_from_command_line + setup_django_environment( + get_user_config_path('openslides', 'settings.py')) execute_from_command_line(sys.argv) diff --git a/openslides/__init__.py b/openslides/__init__.py index 35e4ea998..f32ad47e6 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -5,39 +5,47 @@ :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 the current git commit. """ if version is None: version = VERSION + if release is None: + release = RELEASE 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: # main = X.Y[.Z] # 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 = '.'.join(str(x) for x in version[:main_parts]) - if version[3] != 'final': - if version[3] == 'dev': - try: - 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]) + mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} + sub = mapping[version[3]] + str(version[4]) else: sub = '' - + if not release: + sub += '-dev' 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) diff --git a/openslides/config/views.py b/openslides/config/views.py index c70fa781b..448b3d758 100644 --- a/openslides/config/views.py +++ b/openslides/config/views.py @@ -16,7 +16,7 @@ from django.core.urlresolvers import reverse from django.utils.importlib import import_module 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.views import FormView, TemplateView from .forms import GeneralConfigForm @@ -79,7 +79,14 @@ class VersionConfig(TemplateView): def get_context_data(self, **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: try: mod = import_module(plugin) @@ -90,7 +97,6 @@ class VersionConfig(TemplateView): plugin_name = mod.NAME except AttributeError: plugin_name = mod.__name__.split('.')[0] - context['versions'].append((plugin_name, plugin_version)) return context diff --git a/openslides/global_settings.py b/openslides/global_settings.py index 174d57d09..adb51aea7 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -129,7 +129,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.request', 'django.core.context_processors.i18n', 'django.core.context_processors.static', - 'openslides.utils.utils.revision', 'openslides.utils.auth.anonymous_context_additions', ) diff --git a/openslides/utils/utils.py b/openslides/utils/utils.py index 4c787687a..fa5f96d5e 100644 --- a/openslides/utils/utils.py +++ b/openslides/utils/utils.py @@ -29,12 +29,6 @@ from django.utils.translation import ugettext as _, ugettext_lazy 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): """ diff --git a/tests/test_init.py b/tests/test_init.py index 6155716f1..411860d79 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -9,15 +9,25 @@ from django.test import TestCase -from openslides import get_version +from openslides import get_version, get_git_commit_id class InitTest(TestCase): 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') - self.assertEqual(get_version((2, 5, 3, 'alpha', 0)), '2.5.3-alpha0') - git_version = get_version((2, 5, 0, 'dev', 0)) - if 'unknown' in git_version: - self.assertEqual(len(git_version), 14) - else: - self.assertEqual(len(git_version), 47) + """ + Tests the method during development process and for releases. + """ + self.assertEqual(get_version(version=(1, 3, 0, 'beta', 2), release=False), '1.3b2-dev') + self.assertEqual(get_version(version=(1, 0, 0, 'final', 0), release=False), '1.0-dev') + self.assertEqual(get_version(version=(2, 5, 3, 'alpha', 0), release=False), '2.5.3a0-dev') + self.assertEqual(get_version(version=(1, 3, 0, 'beta', 2), release=True), '1.3b2') + 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)