diff --git a/sanic/response.py b/sanic/response.py index ad263364..07dab381 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -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 diff --git a/setup.py b/setup.py index c73f3848..c5069eaa 100644 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tests/test_request_data.py b/tests/test_request_data.py index c874f71d..c2493ffe 100644 --- a/tests/test_request_data.py +++ b/tests/test_request_data.py @@ -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():