-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Python 2/3 compatibility issues (#57)
- Loading branch information
Showing
11 changed files
with
94 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,7 @@ docs/_build/ | |
|
||
.eggs/ | ||
.pytest_cache/ | ||
|
||
# IDE settings | ||
.vscode | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,9 @@ | ||
try: | ||
# Python 3 | ||
import urllib.parse as urlparse | ||
from urllib.parse import urlencode | ||
from urllib.parse import quote | ||
|
||
def iteritems(a_dict): | ||
return a_dict.items() | ||
|
||
def b(s): | ||
return s.encode("latin-1") | ||
|
||
except ImportError: | ||
# Python 2.7 | ||
import urlparse | ||
from urllib import urlencode | ||
from urllib import quote | ||
|
||
def iteritems(a_dict): | ||
return a_dict.iteritems() | ||
|
||
# Python 2 | ||
def b(s): | ||
return s | ||
|
||
__all__ = ['iteritems', 'quote', 'urlparse', 'urlencode'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import codecs | ||
import io | ||
import re | ||
|
||
from imgix._version import __version__ | ||
from setuptools import setup | ||
|
||
with io.open("imgix/_version.py", "rt", encoding="utf8") as f: | ||
version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1) | ||
|
||
with codecs.open('README.md', encoding='utf-8') as fp: | ||
readme = fp.read() | ||
with codecs.open('CHANGELOG.md', encoding='utf-8') as fp: | ||
changelog = fp.read() | ||
|
||
test_require = [ | ||
'pytest', | ||
'pytest-cov', | ||
'flake8', | ||
] | ||
|
||
setup( | ||
name='imgix', | ||
version=__version__, | ||
version=version, | ||
author='imgix', | ||
author_email='[email protected]', | ||
packages=['imgix'], | ||
|
@@ -36,9 +44,13 @@ | |
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
], | ||
setup_requires=['pytest-runner'], | ||
tests_require=[ | ||
'pytest', | ||
'pytest-cov', | ||
install_requires=[ | ||
'future', | ||
], | ||
) | ||
setup_requires=['pytest-runner'], | ||
extras_require={ | ||
'dev': ['tox'], | ||
'test': test_require, | ||
}, | ||
tests_require=test_require, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
|
||
if os.environ.get('COMPAT_ENV'): | ||
# Due to how PyTest runs tests, it is not possible to | ||
# call `install_aliases` on a per-test basis. | ||
# To workaround this, we rely on Tox conditionally setting | ||
# this env variable to run all the tests with and without the | ||
# compatibility aliases. | ||
from future import standard_library | ||
standard_library.install_aliases() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
[tox] | ||
envlist = flake8, core, py27 | ||
envlist = flake8, core, compat, py27, py27-compat | ||
|
||
[flake8] | ||
exclude = .tox/* | ||
|
||
[testenv:core] | ||
deps = | ||
pytest | ||
pytest-cov | ||
commands = | ||
coverage run -m pytest | ||
coverage report | ||
|
||
;uncomment below if an html report is desired | ||
;coverage html | ||
|
||
[testenv:py27] | ||
[testenv] | ||
deps = | ||
pytest | ||
pytest-cov | ||
.[test] | ||
commands = | ||
coverage run -m pytest | ||
coverage report | ||
pytest --cov=imgix {posargs} | ||
setenv = | ||
compat: COMPAT_ENV=True | ||
|
||
[testenv:flake8] | ||
deps = flake8 | ||
commands = flake8 setup.py imgix tests | ||
commands = | ||
flake8 setup.py imgix tests |