mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Drop support of python 2.6, 3.2 and Django < 1.8
This commit is contained in:
parent
abe1890c5b
commit
063bf61a16
7 changed files with 51 additions and 136 deletions
24
.travis.yml
24
.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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ Changelog
|
|||
v1.0.1 (Not yet released)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- Drop support of python2.6 and python3.2
|
||||
- Drop support of Django < 1.8
|
||||
|
||||
|
||||
v1.0 (2016-01-04)
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
]
|
||||
|
||||
# ...
|
||||
# ...
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
22
tox.ini
22
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue