mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 05:20:12 +03:00
Added conditional Cython extension build step in setup.py and created speedups for some renderers.
This commit is contained in:
parent
2580466ffc
commit
748f2fc533
0
rest_framework/__init__.pxd
Normal file
0
rest_framework/__init__.pxd
Normal file
23
rest_framework/renderers.pxd
Normal file
23
rest_framework/renderers.pxd
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
cimport cython
|
||||
|
||||
@cython.locals(media_type=unicode, format=unicode, charset=unicode, render_style=unicode)
|
||||
cdef class BaseRenderer(object):
|
||||
"""
|
||||
All renderers should extend this class, setting the `media_type`
|
||||
and `format` attributes, and override the `.render()` method.
|
||||
"""
|
||||
|
||||
@cython.locals(indent=int, separators=tuple)
|
||||
cpdef object render(self, dict data, accepted_media_type=?, renderer_context=?)
|
||||
|
||||
@cython.locals(compact=bool, ensure_ascii=bool, charset=unicode)
|
||||
cdef class JSONRenderer(BaseRenderer):
|
||||
@cython.locals(base_media_type=unicode, params=dict)
|
||||
cpdef int get_indent(self, unicode accepted_media_type, dict renderer_context)
|
||||
|
||||
@cython.locals(callback_parameter=unicode, default_callback=unicode)
|
||||
cdef class JSONPRenderer(JSONRenderer):
|
||||
cpdef unicode get_callback(self, dict renderer_context)
|
20
setup.py
20
setup.py
|
@ -1,12 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from setuptools import setup
|
||||
from setuptools.command.test import test as TestCommand
|
||||
try:
|
||||
from Cython.Build import cythonize
|
||||
except ImportError:
|
||||
ext_modules = None
|
||||
else:
|
||||
from setuptools import Extension
|
||||
ext_modules = cythonize(Extension('speedups', ['rest_framework/renderers.py',
|
||||
'rest_framework/__init__.py']))
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
def get_version(package):
|
||||
"""
|
||||
|
@ -43,7 +52,6 @@ def get_package_data(package):
|
|||
|
||||
version = get_version('rest_framework')
|
||||
|
||||
|
||||
if sys.argv[-1] == 'publish':
|
||||
if os.system("pip freeze | grep wheel"):
|
||||
print("wheel not installed.\nUse `pip install wheel`.\nExiting.")
|
||||
|
@ -55,7 +63,6 @@ if sys.argv[-1] == 'publish':
|
|||
print(" git push --tags")
|
||||
sys.exit()
|
||||
|
||||
|
||||
setup(
|
||||
name='djangorestframework',
|
||||
version=version,
|
||||
|
@ -68,6 +75,7 @@ setup(
|
|||
package_data=get_package_data('rest_framework'),
|
||||
install_requires=[],
|
||||
zip_safe=False,
|
||||
ext_modules=ext_modules,
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Web Environment',
|
||||
|
@ -82,7 +90,7 @@ setup(
|
|||
)
|
||||
|
||||
# (*) Please direct queries to the discussion group, rather than to me directly
|
||||
# Doing so helps ensure your question is helpful to other users.
|
||||
# Queries directly to my email are likely to receive a canned response.
|
||||
# Doing so helps ensure your question is helpful to other users.
|
||||
# Queries directly to my email are likely to receive a canned response.
|
||||
#
|
||||
# Many thanks for your understanding.
|
||||
|
|
Loading…
Reference in New Issue
Block a user