Skip to content

Commit

Permalink
feat: make it work with newer hiredis & upgrade CI python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
galuszkak committed Jul 2, 2018
1 parent 2636dba commit 5cf515f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 72 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
language: python

python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"

branches:
only:
Expand All @@ -16,7 +14,6 @@ branches:
- master

install:
- if [[ $TRAVIS_PYTHON_VERSION == "3.2" ]]; then travis_retry pip install --upgrade "setuptools<30.0.0"; fi
- python setup.py build

script: "python test.py"
29 changes: 15 additions & 14 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,35 @@ environment:

matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.8"
PYTHON_VERSION: "2.7.15"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.8"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python33"
PYTHON_VERSION: "3.3.5"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python33-x64"
PYTHON_VERSION: "3.3.5"
PYTHON_VERSION: "2.7.15"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4.1"
PYTHON_VERSION: "3.4.4"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python34-x64"
PYTHON_VERSION: "3.4.1"
PYTHON_VERSION: "3.4.4"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.0"
PYTHON_VERSION: "3.5.3"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5.0"
PYTHON_VERSION: "3.5.3"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python36"
PYTHON_VERSION: "3.6.5"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6.5"
PYTHON_ARCH: "64"

install:
Expand Down
2 changes: 1 addition & 1 deletion hiredis/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0"
__version__ = "0.3.0"
101 changes: 53 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
#!/usr/bin/env python

try:
from setuptools import setup, Extension
from setuptools.command import install_lib as _install_lib
from setuptools import setup, Extension
from setuptools.command import install_lib as _install_lib
except ImportError:
from distutils.core import setup, Extension
from distutils.command import install_lib as _install_lib
import sys, imp, os, glob
from distutils.core import setup, Extension
from distutils.command import install_lib as _install_lib
import imp
import glob


def version():
module = imp.load_source("hiredis.version", "hiredis/version.py")
return module.__version__
module = imp.load_source("hiredis.version", "hiredis/version.py")
return module.__version__


# Patch "install_lib" command to run build_clib before build_ext
# to properly work with easy_install.
# See: http://bugs.python.org/issue5243
class install_lib(_install_lib.install_lib):
def build(self):
if not self.skip_build:
if self.distribution.has_pure_modules():
self.run_command('build_py')
if self.distribution.has_c_libraries():
self.run_command('build_clib')
if self.distribution.has_ext_modules():
self.run_command('build_ext')
def build(self):
if not self.skip_build:
if self.distribution.has_pure_modules():
self.run_command('build_py')
if self.distribution.has_c_libraries():
self.run_command('build_clib')
if self.distribution.has_ext_modules():
self.run_command('build_ext')


# To link the extension with the C library, distutils passes the "-lLIBRARY"
# option to the linker. This makes it go through its library search path. If it
Expand All @@ -41,43 +45,44 @@ def build(self):
#
# Also see: https://github.com/pietern/hiredis-py/issues/15
lib = ("hiredis_for_hiredis_py", {
"sources": ["vendor/hiredis/%s.c" % src for src in ("read", "sds")]})
"sources": ["vendor/hiredis/%s.c" % src for src in ("read", "sds")]})

ext = Extension("hiredis.hiredis",
sources=sorted(glob.glob("src/*.c")),
include_dirs=["vendor"])
sources=sorted(glob.glob("src/*.c")),
include_dirs=["vendor"])

setup(
name="hiredis",
version=version(),
description="Python wrapper for hiredis",
url="https://github.com/redis/hiredis-py",
author="Jan-Erik Rediger, Pieter Noordhuis",
author_email="[email protected], [email protected]",
keywords=["Redis"],
license="BSD",
packages=["hiredis"],
libraries=[lib],
ext_modules=[ext],
name="hiredis",
version=version(),
description="Python wrapper for hiredis",
url="https://github.com/redis/hiredis-py",
author="Jan-Erik Rediger, Pieter Noordhuis",
author_email="[email protected], [email protected]",
keywords=["Redis"],
license="BSD",
packages=["hiredis"],
libraries=[lib],
ext_modules=[ext],

# Override "install_lib" command
cmdclass={ "install_lib": install_lib },
# Override "install_lib" command
cmdclass={
"install_lib": install_lib
},

classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS',
'Operating System :: POSIX',
'Programming Language :: C',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development',
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS',
'Operating System :: POSIX',
'Programming Language :: C',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development',
],
)
8 changes: 4 additions & 4 deletions src/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ redisReplyObjectFunctions hiredis_ObjectFunctions = {
};

static void Reader_dealloc(hiredis_ReaderObject *self) {
redisReplyReaderFree(self->reader);
redisReaderFree(self->reader);
if (self->encoding)
free(self->encoding);
Py_XDECREF(self->protocolErrorClass);
Expand Down Expand Up @@ -269,7 +269,7 @@ static PyObject *Reader_feed(hiredis_ReaderObject *self, PyObject *args) {
goto error;
}

redisReplyReaderFeed(self->reader, (char *)buf.buf + off, len);
redisReaderFeed(self->reader, (char *)buf.buf + off, len);
PyBuffer_Release(&buf);
Py_RETURN_NONE;

Expand All @@ -283,8 +283,8 @@ static PyObject *Reader_gets(hiredis_ReaderObject *self) {
PyObject *err;
char *errstr;

if (redisReplyReaderGetReply(self->reader, (void**)&obj) == REDIS_ERR) {
errstr = redisReplyReaderGetError(self->reader);
if (redisReaderGetReply(self->reader, (void**)&obj) == REDIS_ERR) {
errstr = redisReaderGetError(self->reader);
/* protocolErrorClass might be a callable. call it, then use it's type */
err = createError(self->protocolErrorClass, errstr, strlen(errstr));
obj = PyObject_Type(err);
Expand Down
2 changes: 1 addition & 1 deletion vendor/hiredis
Submodule hiredis updated 22 files
+21 −0 .travis.yml
+43 −1 CHANGELOG.md
+11 −15 Makefile
+23 −4 README.md
+12 −12 adapters/libevent.h
+3 −2 adapters/libuv.h
+23 −0 appveyor.yml
+37 −8 async.c
+1 −0 async.h
+2 −2 dict.c
+1 −1 examples/example.c
+4 −13 fmacros.h
+19 −34 hiredis.c
+3 −27 hiredis.h
+42 −23 net.c
+0 −4 net.h
+117 −44 read.c
+4 −9 read.h
+342 −165 sds.c
+184 −16 sds.h
+42 −0 sdsalloc.h
+130 −14 test.c

0 comments on commit 5cf515f

Please sign in to comment.