Skip to content

Commit

Permalink
Drop Python 2 / Django 1.11
Browse files Browse the repository at this point in the history
Code compatibility layers to support python, old django will be removed in a future commit / PR
  • Loading branch information
yakky committed Apr 26, 2020
1 parent 20e3b47 commit 4e6c0ea
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 467 deletions.
5 changes: 0 additions & 5 deletions .gitlab-ci.yml

This file was deleted.

11 changes: 2 additions & 9 deletions .travis.yml
Expand Up @@ -6,7 +6,6 @@ python:
- 3.7
- 3.6
- 3.5
- 2.7

env:

Expand All @@ -28,8 +27,7 @@ before_install:

# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- pip install -U setuptools tox virtualenv coveralls
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export TOX_ENV=py27; fi"
- pip install -U setuptools tox virtualenv coveralls>=2
- "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export TOX_ENV=py35; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export TOX_ENV=py36; fi"
- "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export TOX_ENV=py37; fi"
Expand All @@ -40,17 +38,12 @@ install:
script: COMMAND='coverage run --source=djangocms_installer' tox -e$TOX_ENV

after_success:
- coverage report -m
- codecov
- coveralls

matrix:
exclude:
- python: 2.7
env: TEST='pep8'
- python: 2.7
env: TEST='isort'
- python: 2.7
env: TEST='docs'
- python: 3.5
env: TEST='pep8'
- python: 3.5
Expand Down
40 changes: 9 additions & 31 deletions README.rst
Expand Up @@ -16,28 +16,8 @@ project.

Refer to `django CMS Tutorial`_ on how to properly setup your first django CMS project.

.. warning:: For all 1.2 RC django CMS 3.7 rc will be installed by default, **not** latest stable,
to ensure a smoother transition. Likewise "3.7", "stable" and "lts" selector will install
django CMS 3.7rc1

.. warning:: Version 1.2 dropped support for Python 3.4, django CMS < 3.6 and Django < 1.11.
More 1.1.x versions may be released after 1.2 is out in case important bugfixes will
be needed.

.. warning:: Due to some incompatibilities between psycopg2 2.8 and Django 2.1+ we ship with psycopg2 2.7
when PostgreSQL database is selected, this in turn trigger an outdated psycopg2 warning. To
silence it, add the following to your ``manage.py``:

.. code-block:: python
import os
import sys
import warnings
if __name__ == '__main__':
warnings.filterwarnings(
'ignore', r'The psycopg2.*release 2\.8', UserWarning, 'psycopg2')
# ... rest of code ...
.. warning:: Version 2.0 dropped support for Python 2.7, django CMS < 3.7 and Django < 2.2.
More 1.2.x versions may be released after 1.2 is out in case important bugfixes will be needed.

Usage
-----
Expand Down Expand Up @@ -88,15 +68,13 @@ Supported versions

The current supported version matrix is the following:

+----------------+-------------+-------------+---------------+--------------+--------------+
| | Django 1.11 | Django 2.0 | Django 2.1 | Django 2.2 | Django 3.0 |
+----------------+-------------+-------------+---------------+--------------+--------------+
| django CMS 3.6 | Supported | Supported | Supported | Supported | Supported |
+----------------+-------------+-------------+---------------+--------------+--------------+
| django CMS 3.7 | Supported | Supported | Supported | Supported | Supported |
+----------------+-------------+-------------+---------------+--------------+--------------+
+----------------+--------------+--------------+
| | Django 2.2 | Django 3.0 |
+----------------+--------------+--------------+
| django CMS 3.7 | Supported | Supported |
+----------------+--------------+--------------+

See `version 1.1`_ for older Django / django CMS versions support
See `version 1.2`_ for older Django / django CMS versions support

Any beta and develop version of Django and django CMS, by its very nature,
it's not supported, while it still may work.
Expand Down Expand Up @@ -127,7 +105,7 @@ Please check that the ``.py`` extension is associated correctly with Python inte
Python.File="C:\Windows\py.exe" "%1" %*


.. _version 1.1: https://github.com/nephila/djangocms-installer/tree/release/1.1.x#supported-versions
.. _version 1.2: https://github.com/nephila/djangocms-installer/tree/release/1.2.x#supported-versions
.. _django CMS Tutorial: https://django-cms.readthedocs.io/en/latest/introduction/index.html
.. _installer usage page: http://djangocms-installer.readthedocs.io/en/latest/usage.html

Expand Down
17 changes: 3 additions & 14 deletions djangocms_installer/config/__init__.py
Expand Up @@ -275,21 +275,14 @@ def parse(args):
requirements.extend(data.REQUIREMENTS['cms-master'])
elif LooseVersion(cms_version) >= LooseVersion('3.7'):
requirements.extend(data.REQUIREMENTS['cms-3.7'])
elif LooseVersion(cms_version) >= LooseVersion('3.6'):
requirements.extend(data.REQUIREMENTS['cms-3.6'])

if not args.no_db_driver:
if args.db_driver == 'psycopg2' and django_version in ('1.11', '2.0', '2.1'):
requirements.append('psycopg2<2.8')
else:
requirements.append(args.db_driver)
requirements.append(args.db_driver)
if not args.no_plugins:
if args.cms_version in ('rc', 'develop'):
requirements.extend(data.REQUIREMENTS['plugins-master'])
elif LooseVersion(cms_version) >= LooseVersion('3.7'):
requirements.extend(data.REQUIREMENTS['plugins-3.7'])
elif LooseVersion(cms_version) >= LooseVersion('3.6'):
requirements.extend(data.REQUIREMENTS['plugins-3.6'])
requirements.extend(data.REQUIREMENTS['filer'])

# Django version check
Expand All @@ -304,12 +297,8 @@ def parse(args):

if django_version == '2.2':
requirements.extend(data.REQUIREMENTS['django-2.2'])
elif django_version == '2.1':
requirements.extend(data.REQUIREMENTS['django-2.1'])
elif django_version == '2.0':
requirements.extend(data.REQUIREMENTS['django-2.0'])
elif django_version == '1.11':
requirements.extend(data.REQUIREMENTS['django-1.11'])
elif django_version == '3.0':
requirements.extend(data.REQUIREMENTS['django-3.0'])

requirements.extend(data.REQUIREMENTS['default'])

Expand Down
65 changes: 12 additions & 53 deletions djangocms_installer/config/data.py
Expand Up @@ -18,37 +18,33 @@
**bust
)
DJANGOCMS_BETA = DJANGOCMS_RC
DJANGOCMS_36 = 'django-cms>=3.6,<3.7'

if sys.version_info > (3, 0):
DJANGOCMS_37 = 'django-cms>=3.7,<3.8'
else:
DJANGOCMS_37 = 'django-cms>=3.7,<3.7.2'

if sys.version_info >= (3, 5):
DJANGOCMS_SUPPORTED = ('3.6', '3.7', 'stable', 'lts', 'develop', 'rc')
DJANGOCMS_SUPPORTED = ('3.7', 'stable', 'lts', 'develop', 'rc')
DJANGOCMS_STABLE = '3.7'
DJANGOCMS_LTS = '3.7'
else:
DJANGOCMS_SUPPORTED = ('3.6', '3.7', 'stable', 'lts', 'develop', 'rc')
DJANGOCMS_SUPPORTED = ('3.7', 'stable', 'lts', 'develop', 'rc')
DJANGOCMS_STABLE = '3.7'
DJANGOCMS_LTS = '3.7'
DJANGOCMS_DEFAULT = DJANGOCMS_STABLE

DJANGO_DEVELOP = 'https://github.com/django/django/archive/master.zip?{bust}'.format(**bust)
DJANGO_BETA = 'https://github.com/django/django/archive/master.zip?{bust}'.format(**bust)
if sys.version_info >= (3, 6):
DJANGO_SUPPORTED = ('1.11', '2.0', '2.1', '2.2', '3.0', 'stable', 'lts')
DJANGO_STABLE = '3.0'
DJANGO_LTS = '2.2'
elif (3, 6) > sys.version_info >= (3, 5):
DJANGO_SUPPORTED = ('1.11', '2.0', '2.1', '2.2', 'stable', 'lts')
if sys.version_info < (3, 6):
DJANGO_SUPPORTED = ('2.2', 'stable', 'lts')
DJANGO_STABLE = '2.2'
DJANGO_LTS = '2.2'
else:
DJANGO_SUPPORTED = ('1.11', 'stable', 'lts')
DJANGO_STABLE = '1.11'
DJANGO_LTS = '1.11'
DJANGO_SUPPORTED = ('2.2', '3.0', 'stable', 'lts')
DJANGO_STABLE = '3.0'
DJANGO_LTS = '2.2'

DJANGO_DEFAULT = DJANGO_STABLE

CMS_VERSION_MATRIX = {
Expand All @@ -66,14 +62,12 @@
'develop': DJANGO_STABLE
}
VERSION_MATRIX = {
'3.6': ('1.11', '2.1'),
'3.7': ('1.11', '3.0'),
DJANGOCMS_BETA: ('1.11', '3.0'),
DJANGOCMS_RC: ('1.11', '3.0'),
DJANGOCMS_DEVELOP: ('1.11', '2.2', '3.0'),
'3.7': ('2.2', '3.0'),
DJANGOCMS_BETA: ('2.2', '3.0'),
DJANGOCMS_RC: ('2.2', '3.0'),
DJANGOCMS_DEVELOP: ('2.2', '3.0'),
}
PACKAGE_MATRIX = {
'3.6': DJANGOCMS_36,
'3.7': DJANGOCMS_37,
DJANGOCMS_RC: DJANGOCMS_RC,
DJANGOCMS_BETA: DJANGOCMS_BETA,
Expand All @@ -87,22 +81,6 @@
'six',
'pytz',
],
'django-1.11': [
'django-classy-tags>=0.9',
'django-sekizai>=1.0',
'django-mptt>0.9',
'django-formtools>=2.1,<2.2',
],
'django-2.0': [
'django-classy-tags>=0.9',
'django-sekizai>=1.0',
'django-mptt>0.9',
],
'django-2.1': [
'django-classy-tags>=0.9',
'django-sekizai>=1.0',
'django-mptt>0.9',
],
'django-2.2': [
'django-classy-tags>=0.9',
'django-sekizai>=1.0',
Expand All @@ -113,13 +91,6 @@
'django-sekizai>=1.0',
'django-mptt>0.9',
],
'reversion-django-1.11': [
'django-reversion>=2.0,<2.1',
],
'cms-3.6': [
'djangocms-admin-style>=1.5,<1.6',
'django-treebeard>=4.0,<5.0',
],
'cms-3.7': [
'djangocms-admin-style>=1.5,<1.6',
'django-treebeard>=4.0,<5.0',
Expand All @@ -128,18 +99,6 @@
'https://github.com/divio/djangocms-admin-style/archive/master.zip?{bust}'.format(**bust),
'django-treebeard>=4.0,<5.0',
],
'plugins-3.6': [
'djangocms-text-ckeditor>=3.7,<4.0',
'djangocms-link>=2.5,<2.7',
'djangocms-icon>=1.4,<1.6',
'djangocms-style>=2.2,<2.4',
'djangocms-googlemap>=1.3,<1.5',
'djangocms-snippet>=2.2,<2.4',
'djangocms-video>=2.1,<2.4',
'djangocms-file>=2.3,<2.5',
'djangocms-picture>=2.3,<2.5',
'djangocms-bootstrap4>=1.5,<1.7',
],
'plugins-3.7': [
'djangocms-text-ckeditor>=3.7,<4.0',
'djangocms-link>=2.5,<2.7',
Expand Down
13 changes: 3 additions & 10 deletions djangocms_installer/django/__init__.py
Expand Up @@ -10,17 +10,13 @@
import textwrap
from copy import copy, deepcopy
from distutils.version import LooseVersion
from shlex import quote as shlex_quote

from six import iteritems

from ..config import data, get_settings
from ..utils import chdir, format_val

try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote


def create_project(config_data):
"""
Expand Down Expand Up @@ -122,7 +118,7 @@ def patch_settings(config_data):
current_django_version = LooseVersion(django.__version__)
declared_django_version = LooseVersion(config_data.django_version)

if not os.path.exists(config_data.settings_path):
if not os.path.exists(config_data.settings_path): # pragma: no cover
sys.stderr.write(
'Error while creating target project, '
'please check the given configuration: {0}\n'.format(config_data.settings_path)
Expand Down Expand Up @@ -194,10 +190,7 @@ def patch_settings(config_data):
item_re = re.compile(r'{0} = [^\]]+\]'.format(item), re.DOTALL | re.MULTILINE)
original = item_re.sub('', original)
# TEMPLATES is special, so custom regexp needed
if declared_django_version >= LooseVersion('2.0'):
item_re = re.compile(r'TEMPLATES = .+\},\n\s+\},\n]$', re.DOTALL | re.MULTILINE)
else:
item_re = re.compile(r'TEMPLATES = .+\]$', re.DOTALL | re.MULTILINE)
item_re = re.compile(r'TEMPLATES = .+\},\n\s+\},\n]$', re.DOTALL | re.MULTILINE)
original = item_re.sub('', original)
# DATABASES is a dictionary, so different regexp needed
item_re = re.compile(r'DATABASES = [^\}]+\}[^\}]+\}', re.DOTALL | re.MULTILINE)
Expand Down
15 changes: 6 additions & 9 deletions djangocms_installer/utils.py
Expand Up @@ -102,25 +102,22 @@ def less_than_version(value):
if len(items) == 1:
items.append(0)
items[1] += 1
if value == '1.11':
return '2.0'
else:
return '.'.join(map(str, items))
return '.'.join(map(str, items))


class chdir(object):
"""
Context manager for changing the current working directory
"""
def __init__(self, newPath):
self.newPath = newPath
def __init__(self, new_path):
self.new_path = new_path

def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.newPath)
self.saved_path = os.getcwd()
os.chdir(self.new_path)

def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)
os.chdir(self.saved_path)


def format_val(val):
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Expand Up @@ -3,4 +3,4 @@ flake8
tox
mock
pillow
coverage<5.0
coverage>=5

0 comments on commit 4e6c0ea

Please sign in to comment.