diff --git a/.travis.yml b/.travis.yml index 12addb707b45a69a06a4f1cabb3175db08740030..ae1831d151c1729074a5d2bcb939f78f0411fbad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ before_script: - pip install -r requirements.txt - pip install pytest coverage pytest-cov - DEBUG=1 python setup.py install - - rm -rf minijson jobs: include: - stage: test diff --git a/Dockerfile b/Dockerfile index 7a93d2b57bb9743ca44d88f19f7a4b58e2508964..1d32eca97e10e17c400ee2a1189fa0ceeef9fc11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,5 @@ WORKDIR /tmp/compile ADD . /tmp/compile/ RUN python setup.py install -RUN rm -rf minijson CMD ["pytest", "--cov=./", "--cov-report=xml"] diff --git a/README.md b/README.md index 4ca0bc0685c1dade5765f05dd7328cfc0318f899..01b88e922601f2f0594b721cc868b6e186e91da3 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,4 @@ for use. If there are no binary wheels precompiled for this platform, you will need to compile it yourself. -In order to do that you must have the following packages installed: - -* snakehouse -* satella -* Cython +In order to do that you must have `Cython` installed. diff --git a/minijson/routines.pyx b/minijson.pyx similarity index 98% rename from minijson/routines.pyx rename to minijson.pyx index bce59dea4bff6c8079dd859c20b1c383096a7eea..44ba8c6791c9b91e11431230c4cb78df50b793f7 100644 --- a/minijson/routines.pyx +++ b/minijson.pyx @@ -2,7 +2,22 @@ import typing as tp import io import struct -from minijson.exceptions import DecodingError, EncodingError + +class MiniJSONError(ValueError): + """ + Base class for MiniJSON errors. + + Note that it inherits from :code:`ValueError`. + """ + + +class EncodingError(MiniJSONError): + """Error during encoding""" + + +class DecodingError(MiniJSONError): + """Error during decoding""" + STRUCT_f = struct.Struct('>f') STRUCT_d = struct.Struct('>d') diff --git a/minijson/__init__.py b/minijson/__init__.py deleted file mode 100644 index 5308c4032c94f9bdc1f40bfcd5f64cc100791b96..0000000000000000000000000000000000000000 --- a/minijson/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .routines import dumps, loads, dump, parse, dumps_object, loads_object, \ - switch_default_float, switch_default_double -from .exceptions import MiniJSONError, DecodingError, EncodingError diff --git a/minijson/exceptions.pyx b/minijson/exceptions.pyx deleted file mode 100644 index 19ccbe7d993cc66e2a60dd7506f34a7ef2cba72f..0000000000000000000000000000000000000000 --- a/minijson/exceptions.pyx +++ /dev/null @@ -1,14 +0,0 @@ -class MiniJSONError(ValueError): - """ - Base class for MiniJSON errors. - - Note that it inherits from :code:`ValueError`. - """ - - -class EncodingError(MiniJSONError): - """Error during encoding""" - - -class DecodingError(MiniJSONError): - """Error during decoding""" diff --git a/minijson/routines.pxd b/minijson/routines.pxd deleted file mode 100644 index ceeb54fcbeb41734856c5954c8ed685c70d40e97..0000000000000000000000000000000000000000 --- a/minijson/routines.pxd +++ /dev/null @@ -1,11 +0,0 @@ -import io - -cpdef object loads(bytes data) -cpdef int dump(object data, cio: io.BytesIO) except -1 -cpdef bytes dumps(object data) -cpdef tuple parse(bytes data, int starting_position) -cpdef void switch_default_float() -cpdef void switch_default_double() - -cpdef bytes dumps_object(object data) -cpdef object loads_object(bytes data, object obj_class) diff --git a/requirements.txt b/requirements.txt index 8223c1eaf0a066244831b495d5abaeaf6ef1a04e..002d1b93c6f31187db78e898311d42cbc3991965 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ -snakehouse Cython -satella diff --git a/setup.py b/setup.py index 51baa21d5a965a8dc8d8eb26b95daaeb4b53cc89..746a33613cbee1f55c3af6cbd37821c2e118c1ef 100644 --- a/setup.py +++ b/setup.py @@ -1,34 +1,25 @@ import os -from setuptools import find_packages from distutils.core import setup -from snakehouse import Multibuild, build, monkey_patch_parallel_compilation, find_pyx +from distutils.extension import Extension -monkey_patch_parallel_compilation() +from Cython.Build import cythonize +from Cython.Compiler.Options import get_directive_defaults -build_kwargs = {} -directives = {'language_level': '3'} -dont_snakehouse = False -multi_kwargs = {} + +directive_defaults = get_directive_defaults() +directive_defaults['language_level'] = '3' +macros = [] if 'DEBUG' in os.environ: print('Enabling debug mode') - dont_snakehouse = True - build_kwargs.update(gdb_debug=True) - directives.update(embedsignature=True, - profile=True, - linetrace=True, - binding=True) - multi_kwargs['define_macros'] = [('CYTHON_TRACE', '1'), - ('CYTHON_TRACE_NOGIL', '1')] - - import Cython.Compiler.Options - Cython.Compiler.Options.annotate = True + directive_defaults['linetrace'] = True + directive_defaults['binding'] = True + macros = [('CYTHON_TRACE', '1')] +extensions = [Extension("minijson", ["minijson.pyx"], + define_macros=macros), +] setup(version='1.7', - packages=find_packages(include=['minijson', 'minijson.*']), - ext_modules=build([Multibuild('minijson', find_pyx('minijson'), - dont_snakehouse=dont_snakehouse, - **multi_kwargs), ], - compiler_directives=directives, **build_kwargs), + ext_modules=cythonize(extensions), python_requires='!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*', )