Skip to content
This repository has been archived by the owner on Nov 23, 2020. It is now read-only.

Commit

Permalink
tidy up cython extensions. No more py2 checks. Better dev version to …
Browse files Browse the repository at this point in the history
…avoid warning in command line for #213 #release-note
  • Loading branch information
lsbardel committed Mar 13, 2016
1 parent f0906cf commit 6d369f0
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 110 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Expand Up @@ -2,7 +2,6 @@ include MANIFEST.in
include LICENSE
include README.rst
include runtests.py
include release.py
include docs/make.bat
include docs/Makefile
recursive-exclude * __pycache__
Expand Down
4 changes: 0 additions & 4 deletions extensions/lib/common.pxd

This file was deleted.

46 changes: 0 additions & 46 deletions extensions/lib/common.pyx

This file was deleted.

15 changes: 15 additions & 0 deletions extensions/lib/lib.pxd
@@ -0,0 +1,15 @@

cdef extern from "math.h":
double log(double x)
double sqrt(double x)


cdef double clog2 = log(2.)

cdef inline int int_max(int a, int b): return a if a >= b else b
cdef inline int int_min(int a, int b): return a if a >= b else b


# MSVC does not have log2!
cdef inline double Log2(double x):
return log(x) / clog2
1 change: 0 additions & 1 deletion extensions/lib/lib.pyx
@@ -1,3 +1,2 @@
include "common.pyx"
include "rparser.pyx"
include "websocket.pyx"
4 changes: 2 additions & 2 deletions extensions/lib/rparser.pyx
Expand Up @@ -69,7 +69,7 @@ cdef class RedisParser:
def _pack_command(self, args):
yield ('*%d\r\n' % len(args)).encode('utf-8')
for value in args:
if isinstance(value, strict_string_type):
if isinstance(value, str):
value = value.encode('utf-8')
elif not isinstance(value, bytes):
value = str(value).encode('utf-8')
Expand All @@ -86,7 +86,7 @@ cdef class RedisParser:
yield ('$%d\r\n' % len(value)).encode('utf-8')
yield value
yield CRLF
elif isinstance(value, string_type):
elif isinstance(value, str):
value = value.encode('utf-8')
yield ('$%d\r\n' % len(value)).encode('utf-8')
yield value
Expand Down
52 changes: 0 additions & 52 deletions extensions/lib/utils.h

This file was deleted.

13 changes: 13 additions & 0 deletions extensions/lib/websocket.pxd
@@ -0,0 +1,13 @@

cdef extern from "websocket.h":
object websocket_mask(const char* chunk, const char* key,
size_t chunk_length, size_t mask_length)


cdef inline bytes to_bytes(object value, str encoding):
if isinstance(value, bytes):
return value
elif isinstance(value, str):
return value.encode(encoding)
else:
raise TypeError('Requires bytes or string')
4 changes: 2 additions & 2 deletions extensions/lib/websocket.pyx
Expand Up @@ -2,7 +2,7 @@ import os
from struct import pack, unpack

cimport cython
from common cimport websocket_mask
from websocket cimport websocket_mask, to_bytes


cdef class Frame:
Expand Down Expand Up @@ -281,7 +281,7 @@ cdef class FrameParser:
else:
masking_key = b''
if opcode is None:
opcode = 1 if isinstance(message, string_type) else 2
opcode = 1 if isinstance(message, str) else 2
data = to_bytes(message or b'', 'utf-8')
if opcode not in self._opcodes:
raise self.ProtocolError('WEBSOCKET opcode a reserved value')
Expand Down
3 changes: 2 additions & 1 deletion extensions/setup.py
Expand Up @@ -55,6 +55,7 @@ def lib_extension():

def libparams():
extensions = [lib_extension()]
return {'ext_modules': cythonize(extensions),
return {'ext_modules': cythonize(extensions,
include_path=include_dirs),
'cmdclass': {'build_ext': tolerant_build_ext},
'include_dirs': include_dirs}
2 changes: 1 addition & 1 deletion pulsar/utils/version.py
Expand Up @@ -11,7 +11,7 @@ def get_version(version, filename=None):
if version[3] == 'alpha' and version[4] == 0:
git_changeset = get_git_changeset(filename)
if git_changeset:
sub = '-dev.%s' % git_changeset
sub = '.dev%s' % git_changeset
if version[3] != 'final' and not sub:
sub = '%s%s' % tuple(version[3:])
return main + sub
Expand Down

0 comments on commit 6d369f0

Please sign in to comment.