Default to json if ujson isn't installed. Provide install extras
This commit is contained in:
parent
b87dc37fbb
commit
7a0072a036
|
@ -1,6 +1,10 @@
|
||||||
from mimetypes import guess_type
|
from mimetypes import guess_type
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
try:
|
||||||
from ujson import dumps as json_dumps
|
from ujson import dumps as json_dumps
|
||||||
|
except ImportError:
|
||||||
|
from json import dumps as json_dumps
|
||||||
|
|
||||||
from aiofiles import open as open_async
|
from aiofiles import open as open_async
|
||||||
|
|
||||||
|
|
15
setup.py
15
setup.py
|
@ -17,12 +17,16 @@ with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'httptools>=0.0.9',
|
'httptools>=0.0.9',
|
||||||
'ujson>=1.35',
|
|
||||||
'aiofiles>=0.3.0',
|
'aiofiles>=0.3.0',
|
||||||
]
|
]
|
||||||
|
|
||||||
if os.name != 'nt':
|
ujson = [
|
||||||
install_requires.append('uvloop>=0.5.3')
|
'ujson>=1.35',
|
||||||
|
]
|
||||||
|
|
||||||
|
uvloop = [
|
||||||
|
'uvloop>=0.5.3',
|
||||||
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='sanic',
|
name='sanic',
|
||||||
|
@ -36,6 +40,11 @@ setup(
|
||||||
packages=['sanic'],
|
packages=['sanic'],
|
||||||
platforms='any',
|
platforms='any',
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
|
extras_require={
|
||||||
|
"all": install_requires + ujson + uvloop,
|
||||||
|
"ujson": install_requires + ujson,
|
||||||
|
"uvloop": install_requires + uvloop,
|
||||||
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 2 - Pre-Alpha',
|
'Development Status :: 2 - Pre-Alpha',
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
|
|
|
@ -2,7 +2,7 @@ import random
|
||||||
|
|
||||||
from sanic import Sanic
|
from sanic import Sanic
|
||||||
from sanic.response import json
|
from sanic.response import json
|
||||||
from ujson import loads
|
from json import loads
|
||||||
|
|
||||||
|
|
||||||
def test_storage():
|
def test_storage():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user