Skip to content

Commit

Permalink
Merge pull request #144 from ticosax/remove-old-versions
Browse files Browse the repository at this point in the history
Drop support of python 2.6, 3.2 and Django < 1.8
  • Loading branch information
blueyed committed Jan 27, 2016
2 parents abe1890 + cf3961e commit d66ecc6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 142 deletions.
24 changes: 1 addition & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 3 additions & 7 deletions configurations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']


Expand All @@ -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):
Expand Down
94 changes: 36 additions & 58 deletions configurations/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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
Expand All @@ -29,28 +28,24 @@
def install(check_options=False):
global installed
if not installed:
if DJANGO_VERSION >= (1, 8):
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

base.BaseCommand.create_parser = create_parser
else:
# add the configuration option to all management commands
base.BaseCommand.option_list += configuration_options
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

base.BaseCommand.create_parser = create_parser
importer = ConfigurationImporter(check_options=check_options)
sys.meta_path.insert(0, importer)
installed = True
Expand Down Expand Up @@ -87,35 +82,22 @@ def name(self):
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.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 = 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.

def validate(self):
if self.name is None:
Expand All @@ -127,13 +109,9 @@ def announce(self):
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):
Expand Down
7 changes: 5 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 9 additions & 28 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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
^^^^^^
Expand Down Expand Up @@ -267,4 +248,4 @@ the environment variable accordingly:
'configurations',
]
# ...
# ...
5 changes: 1 addition & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
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

Expand Down
22 changes: 2 additions & 20 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d66ecc6

Please sign in to comment.