Default to json if ujson isn't installed. Provide install extras

This commit is contained in:
Jakob Bowyer 2017-03-02 11:22:47 +00:00
parent b87dc37fbb
commit 7a0072a036
3 changed files with 18 additions and 5 deletions

View File

@ -1,6 +1,10 @@
from mimetypes import guess_type
from os import path
from ujson import dumps as json_dumps
try:
from ujson import dumps as json_dumps
except ImportError:
from json import dumps as json_dumps
from aiofiles import open as open_async

View File

@ -17,12 +17,16 @@ with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
install_requires = [
'httptools>=0.0.9',
'ujson>=1.35',
'aiofiles>=0.3.0',
]
if os.name != 'nt':
install_requires.append('uvloop>=0.5.3')
ujson = [
'ujson>=1.35',
]
uvloop = [
'uvloop>=0.5.3',
]
setup(
name='sanic',
@ -36,6 +40,11 @@ setup(
packages=['sanic'],
platforms='any',
install_requires=install_requires,
extras_require={
"all": install_requires + ujson + uvloop,
"ujson": install_requires + ujson,
"uvloop": install_requires + uvloop,
},
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Environment :: Web Environment',

View File

@ -2,7 +2,7 @@ import random
from sanic import Sanic
from sanic.response import json
from ujson import loads
from json import loads
def test_storage():