diff --git a/.travis.yml b/.travis.yml index 91e6c68..30f5e4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,38 +12,16 @@ env: - TOXENV=flake8-py27 - TOXENV=flake8-py35 - TOXENV=readme-py27 - - TOXENV=py26-dj14 - - TOXENV=py26-dj15 - - TOXENV=py26-dj16 - - TOXENV=pypy-dj14 - - TOXENV=pypy-dj15 - - TOXENV=pypy-dj16 - - TOXENV=py27-dj14 - - TOXENV=py27-dj15 - - TOXENV=py27-dj16 - - TOXENV=py27-dj17 - TOXENV=py27-dj18 - TOXENV=py27-dj19 - TOXENV=py27-djmaster - - TOXENV=py32-dj15 - - TOXENV=py32-dj16 - - TOXENV=py32-dj17 - - TOXENV=py32-dj18 - - TOXENV=py33-dj15 - - TOXENV=py33-dj16 - - TOXENV=py33-dj17 - TOXENV=py33-dj18 - - TOXENV=py34-dj15 - - TOXENV=py34-dj16 - - TOXENV=py34-dj17 - TOXENV=py34-dj18 - TOXENV=py34-dj19 + - TOXENV=py34-djmaster - TOXENV=py35-dj18 - TOXENV=py35-dj19 - TOXENV=py35-djmaster - - TOXENV=pypy-dj15 - - TOXENV=pypy-dj16 - - TOXENV=pypy-dj17 - TOXENV=pypy-dj18 - TOXENV=pypy-dj19 matrix: diff --git a/configurations/__init__.py b/configurations/__init__.py index 8e05355..6256779 100644 --- a/configurations/__init__.py +++ b/configurations/__init__.py @@ -2,7 +2,7 @@ from .base import Settings, Configuration from .decorators import pristinemethod -__version__ = '1.0.1.dev' +__version__ = '2.0.dev' __all__ = ['Configuration', 'pristinemethod', 'Settings'] @@ -11,12 +11,8 @@ def _setup(): importer.install() - # django >=1.7 - try: - import django - django.setup() - except AttributeError: - pass + import django + django.setup() def load_ipython_extension(ipython): diff --git a/configurations/importer.py b/configurations/importer.py index 1dad4d7..06b64fb 100644 --- a/configurations/importer.py +++ b/configurations/importer.py @@ -4,7 +4,6 @@ import os import sys from optparse import OptionParser, make_option -from django import VERSION as DJANGO_VERSION from django.conf import ENVIRONMENT_VARIABLE as SETTINGS_ENVIRONMENT_VARIABLE from django.core.exceptions import ImproperlyConfigured from django.core.management import base @@ -29,28 +28,24 @@ configuration_options = (make_option(CONFIGURATION_ARGUMENT, def install(check_options=False): global installed if not installed: - if DJANGO_VERSION >= (1, 8): - orig_create_parser = base.BaseCommand.create_parser + orig_create_parser = base.BaseCommand.create_parser - def create_parser(self, prog_name, subcommand): - parser = orig_create_parser(self, prog_name, subcommand) - if isinstance(parser, OptionParser): - # in case the option_list is set the create_parser - # will actually return a OptionParser for backward - # compatibility. In that case we should tack our - # options on to the end of the parser on the way out. - for option in configuration_options: - parser.add_option(option) - else: - # probably argparse, let's not import argparse though - parser.add_argument(CONFIGURATION_ARGUMENT, - help=CONFIGURATION_ARGUMENT_HELP) - return parser + def create_parser(self, prog_name, subcommand): + parser = orig_create_parser(self, prog_name, subcommand) + if isinstance(parser, OptionParser): + # in case the option_list is set the create_parser + # will actually return a OptionParser for backward + # compatibility. In that case we should tack our + # options on to the end of the parser on the way out. + for option in configuration_options: + parser.add_option(option) + else: + # probably argparse, let's not import argparse though + parser.add_argument(CONFIGURATION_ARGUMENT, + help=CONFIGURATION_ARGUMENT_HELP) + return parser - base.BaseCommand.create_parser = create_parser - else: - # add the configuration option to all management commands - base.BaseCommand.option_list += configuration_options + base.BaseCommand.create_parser = create_parser importer = ConfigurationImporter(check_options=check_options) sys.meta_path.insert(0, importer) installed = True @@ -87,35 +82,22 @@ class ConfigurationImporter(object): return os.environ.get(self.namevar) def check_options(self): - # django switched to argparse in version 1.8 - if DJANGO_VERSION >= (1, 8): - parser = base.CommandParser(None, - usage="%(prog)s subcommand [options] [args]", - add_help=False) - parser.add_argument('--settings') - parser.add_argument('--pythonpath') - parser.add_argument(CONFIGURATION_ARGUMENT, - help=CONFIGURATION_ARGUMENT_HELP) + parser = base.CommandParser(None, + usage="%(prog)s subcommand [options] [args]", + add_help=False) + parser.add_argument('--settings') + parser.add_argument('--pythonpath') + parser.add_argument(CONFIGURATION_ARGUMENT, + help=CONFIGURATION_ARGUMENT_HELP) - parser.add_argument('args', nargs='*') # catch-all - try: - options, args = parser.parse_known_args(self.argv[2:]) - if options.configuration: - os.environ[self.namevar] = options.configuration - base.handle_default_options(options) - except base.CommandError: - pass # Ignore any option errors at this point. - # django < 1.7 did use optparse - else: - from django.core.management import LaxOptionParser - parser = LaxOptionParser(option_list=configuration_options, - add_help_option=False) - try: - options, args = parser.parse_args(self.argv) - if options.configuration: - os.environ[self.namevar] = options.configuration - except: - pass # Ignore any option errors at this point. + parser.add_argument('args', nargs='*') # catch-all + try: + options, args = parser.parse_known_args(self.argv[2:]) + if options.configuration: + os.environ[self.namevar] = options.configuration + base.handle_default_options(options) + except base.CommandError: + pass # Ignore any option errors at this point. def validate(self): if self.name is None: @@ -127,13 +109,9 @@ class ConfigurationImporter(object): if len(self.argv) > 1: from . import __version__ from django.utils.termcolors import colorize - # Django >= 1.7 supports hiding the colorization in the shell - try: - from django.core.management.color import no_style - except ImportError: - no_style = None + from django.core.management.color import no_style - if no_style is not None and '--no-color' in self.argv: + if '--no-color' in self.argv: stylize = no_style() else: def stylize(text): diff --git a/docs/changes.rst b/docs/changes.rst index 5e9aa41..022ef2d 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -3,8 +3,11 @@ Changelog --------- -v1.0.1 (Not yet released) -^^^^^^^^^^^^^^^^^^^^^^^^^ +v2.0 (Not yet released) +^^^^^^^^^^^^^^^^^^^^^^^ + +- Drop support of python2.6 and python3.2 +- Drop support of Django < 1.8 v1.0 (2016-01-04) diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 8fd2173..8d00133 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -71,46 +71,27 @@ You can use a special Django project template that is a copy of the one included in Django 1.5.x and 1.6.x. The following examples assumes you're using pip_ to install packages. -Django 1.5.x +Django 1.8.x ^^^^^^^^^^^^ -First install Django 1.5.x and django-configurations: +First install Django 1.8.x and django-configurations: .. code-block:: console - $ pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.5.x/requirements.txt + $ pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.8.x/requirements.txt -Then create your new Django project with the provided template: +Or Django 1.8: .. code-block:: console - $ django-admin.py startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.5.x.zip + $ django-admin.py startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.8.x.zip -See the repository of the template for more information: - - https://github.com/jazzband/django-configurations/tree/templates/1.5.x - -Django 1.6.x -^^^^^^^^^^^^ - -First install Django 1.6.x and django-configurations: - -.. code-block:: console - - $ pip install -r https://raw.github.com/jazzband/django-configurations/templates/1.6.x/requirements.txt - -Or Django 1.6: - -.. code-block:: console - - $ django-admin.py startproject mysite -v2 --template https://github.com/jazzband/django-configurations/archive/templates/1.6.x.zip - -Now you have a default Django 1.5.x or 1.6.x project in the ``mysite`` +Now you have a default Django 1.8.x project in the ``mysite`` directory that uses django-configurations. See the repository of the template for more information: - https://github.com/jazzband/django-configurations/tree/templates/1.6.x + https://github.com/jazzband/django-configurations/tree/templates/1.8.x .. _pip: http://pip-installer.org/ @@ -129,7 +110,7 @@ probably just add the following to the **beginning** of your settings module: configurations.setup() That has the same effect as using the ``manage.py`` or ``wsgi.py`` utilities. -This will also call ``django.setup()`` on Django >= 1.7. +This will also call ``django.setup()``. >= 3.1 ^^^^^^ @@ -267,4 +248,4 @@ the environment variable accordingly: 'configurations', ] - # ... \ No newline at end of file + # ... diff --git a/tests/test_main.py b/tests/test_main.py index b7e374c..6eae56f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -7,10 +7,7 @@ from django.conf import global_settings from django.test import TestCase from django.core.exceptions import ImproperlyConfigured -if sys.version_info >= (2, 7): - from unittest import skipIf -else: - from django.utils.unittest import skipIf +from unittest import skipIf from mock import patch diff --git a/tox.ini b/tox.ini index fcdea6c..b70eaf8 100644 --- a/tox.ini +++ b/tox.ini @@ -6,16 +6,12 @@ envlist = flake8-py27, flake8-py35, readme-py27, - py{26,py}-dj{14,15,16}, - py27-dj{14,15,16,17,18,19,master}, - py{32,33,34,py}-dj{15,16,17,18} - py{34,35,py}-dj{19,master} + py33-dj18 + py{27,34,35,py}-dj{18,19,master} [testenv] basepython = - py26: python2.6 py27: python2.7 - py32: python3.2 py33: python3.3 py34: python3.4 py35: python3.5 @@ -26,10 +22,6 @@ setenv = DJANGO_CONFIGURATION = Test deps = -rtests/requirements.txt - dj14: https://github.com/django/django/archive/stable/1.4.x.tar.gz#egg=django - dj15: https://github.com/django/django/archive/stable/1.5.x.tar.gz#egg=django - dj16: https://github.com/django/django/archive/stable/1.6.x.tar.gz#egg=django - dj17: https://github.com/django/django/archive/stable/1.7.x.tar.gz#egg=django dj18: https://github.com/django/django/archive/stable/1.8.x.tar.gz#egg=django dj19: https://github.com/django/django/archive/stable/1.9.x.tar.gz#egg=django djmaster: https://github.com/django/django/archive/master.tar.gz#egg=django @@ -39,16 +31,6 @@ commands = coverage run {envbindir}/django-cadmin test -v2 {posargs:tests} coverage report -# Coverage supports only Python 3.3+ for Python 3. -[testenv:py32-dj15] -commands = {envbindir}/django-cadmin test -v2 {posargs:tests} -[testenv:py32-dj16] -commands = {envbindir}/django-cadmin test -v2 {posargs:tests} -[testenv:py32-dj17] -commands = {envbindir}/django-cadmin test -v2 {posargs:tests} -[testenv:py32-dj18] -commands = {envbindir}/django-cadmin test -v2 {posargs:tests} - [testenv:readme-py27] commands = python setup.py check -r -s deps = readme_renderer