Skip to content

Commit 7302025

Browse files
author
Buky
authored
Merge pull request jazzband#708 from TheBuky/django3-six
Remove django.utils.six to work with Django 3.0
2 parents 1ec17ba + 1b15277 commit 7302025

File tree

11 files changed

+72
-17
lines changed

11 files changed

+72
-17
lines changed

.travis.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,25 @@ matrix:
1818
- env: TOXENV=py36-django22
1919
python: "3.6"
2020
- env: TOXENV=py37-django22
21-
python: "3.7-dev"
22-
- env: TOXENV=py35-django-master
23-
python: "3.5"
21+
python: "3.7"
22+
- env: TOXENV=py36-django30
23+
python: "3.6"
24+
- env: TOXENV=py37-django30
25+
python: "3.7"
26+
- env: TOXENV=py38-django30
27+
python: "3.8"
2428
- env: TOXENV=py36-django-master
2529
python: "3.6"
2630
- env: TOXENV=py37-django-master
27-
python: "3.7-dev"
31+
python: "3.7"
32+
- env: TOXENV=py38-django-master
33+
python: "3.8-dev"
2834
- env: TOXENV=docs
2935
python: "2.7"
3036
allow_failures:
31-
- env: TOXENV=py35-django-master
3237
- env: TOXENV=py36-django-master
3338
- env: TOXENV=py37-django-master
39+
- env: TOXENV=py38-django-master
3440
before_install:
3541
- nvm install node
3642
- nvm use node

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ or just made Pipeline more awesome.
2727
* Brawaga <[email protected]>
2828
* Brian Montgomery <[email protected]>
2929
* Bryan Chow <[email protected]>
30+
3031
* Caio Ariede <[email protected]>
3132
* Camilo Nova <[email protected]>
3233
* Carl Meyer <[email protected]>

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tox and django installed::
3333
Since we use a number of node.js tools, one should first install the node
3434
depencies. We reccomend using [nvm](https://github.com/nvm-sh/nvm#installation-and-update) , tl;dr::
3535

36-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
36+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
3737
nvm install node
3838
nvm use node
3939

pipeline/collector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import django
88
from django.contrib.staticfiles import finders
99
from django.contrib.staticfiles.storage import staticfiles_storage
10-
from django.utils import six
10+
try:
11+
from django.utils.six import iterkeys
12+
except ImportError:
13+
iterkeys = iter
14+
1115

1216
from pipeline.finders import PipelineFinder
1317

@@ -57,7 +61,7 @@ def collect(self, request=None, files=[]):
5761
if files and len(files) == len(found_files):
5862
break
5963

60-
return six.iterkeys(found_files)
64+
return iterkeys(found_files)
6165

6266
def copy_file(self, path, prefixed_path, source_storage):
6367
# Delete the target file if needed or break

pipeline/compilers/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
from django.contrib.staticfiles.storage import staticfiles_storage
1010
from django.core.files.base import ContentFile
1111
from django.utils.encoding import smart_bytes
12-
from django.utils.six import string_types, text_type
12+
try:
13+
from django.utils.six import string_types, text_type
14+
except ImportError:
15+
string_types = (str,)
16+
text_type = str
1317

1418
from pipeline.conf import settings
1519
from pipeline.exceptions import CompilerError

pipeline/compressors/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
from django.contrib.staticfiles.storage import staticfiles_storage
1212
from django.utils.encoding import smart_bytes, force_text
13-
from django.utils.six import string_types
13+
try:
14+
from django.utils.six import string_types
15+
except ImportError:
16+
string_types = (str,)
1417

1518
from pipeline.conf import settings
1619
from pipeline.exceptions import CompressorError

pipeline/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
from django.conf import settings as _settings
99
from django.core.signals import setting_changed
1010
from django.dispatch import receiver
11-
from django.utils.six import string_types
11+
try:
12+
from django.utils.six import string_types
13+
except ImportError:
14+
string_types = (str,)
1215

1316

1417
DEFAULTS = {

pipeline/decorator.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
"""
5+
This code is a part of django.utils.six on https://github.com/django/django/blob/stable/2.2.x/django/utils/six.py removed form Django 3.0
6+
To keep the backward compatibility between python 2 and 3 the decorator need to be used as well, during the time we find a proper way to
7+
handle MetaClass overwright working on both versions (or dropping python 2 support).
8+
"""
9+
10+
def add_metaclass(metaclass):
11+
"""Class decorator for creating a class with a metaclass."""
12+
def wrapper(cls):
13+
orig_vars = cls.__dict__.copy()
14+
slots = orig_vars.get('__slots__')
15+
if slots is not None:
16+
if isinstance(slots, str):
17+
slots = [slots]
18+
for slots_var in slots:
19+
orig_vars.pop(slots_var)
20+
orig_vars.pop('__dict__', None)
21+
orig_vars.pop('__weakref__', None)
22+
return metaclass(cls.__name__, cls.__bases__, orig_vars)
23+
return wrapper

pipeline/forms.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
from __future__ import unicode_literals
44

55
from django.contrib.staticfiles.storage import staticfiles_storage
6-
from django.utils import six
76
from django.utils.functional import cached_property
7+
try:
8+
from django.utils.six import iteritems, add_metaclass
9+
except ImportError:
10+
from .decorator import add_metaclass
11+
def iteritems(dictionary):
12+
return dictionary.items()
813

914
from .collector import default_collector
1015
from .conf import settings
@@ -168,7 +173,7 @@ def _get_css_files(cls, extra_files):
168173
media_type='css',
169174
extra_files=extra_files.get(media_target,
170175
[])))
171-
for media_target, media_packages in six.iteritems(css_packages)
176+
for media_target, media_packages in iteritems(css_packages)
172177
)
173178

174179
def _get_js_files(cls, extra_files):
@@ -233,7 +238,7 @@ def _get_media_files(cls, packager, media_packages, media_type,
233238
return source_files
234239

235240

236-
@six.add_metaclass(PipelineFormMediaMetaClass)
241+
@add_metaclass(PipelineFormMediaMetaClass)
237242
class PipelineFormMedia(object):
238243
"""Base class for form or widget Media classes that use Pipeline packages.
239244

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='django-pipeline',
9-
version='1.6.14',
9+
version='1.7.0',
1010
description='Pipeline is an asset packaging library for Django.',
1111
long_description=io.open('README.rst', encoding='utf-8').read() + '\n\n' +
1212
io.open('HISTORY.rst', encoding='utf-8').read(),
@@ -27,6 +27,7 @@
2727
'Framework :: Django :: 1.11',
2828
'Framework :: Django :: 2.0',
2929
'Framework :: Django :: 2.2',
30+
'Framework :: Django :: 3.0',
3031
'Intended Audience :: Developers',
3132
'License :: OSI Approved :: MIT License',
3233
'Operating System :: OS Independent',
@@ -36,6 +37,7 @@
3637
'Programming Language :: Python :: 3.5',
3738
'Programming Language :: Python :: 3.6',
3839
'Programming Language :: Python :: 3.7',
40+
'Programming Language :: Python :: 3.8',
3941
'Programming Language :: Python :: Implementation :: PyPy',
4042
'Topic :: Utilities',
4143
'Topic :: Software Development :: Libraries :: Python Modules',

0 commit comments

Comments
 (0)