Code Monkey home page Code Monkey logo

hiredis-py's Introduction

This README is just a fast quick start document. You can find more detailed documentation at redis.io.

What is Redis?

Redis is often referred to as a data structures server. What this means is that Redis provides access to mutable data structures via a set of commands, which are sent using a server-client model with TCP sockets and a simple protocol. So different processes can query and modify the same data structures in a shared way.

Data structures implemented into Redis have a few special properties:

  • Redis cares to store them on disk, even if they are always served and modified into the server memory. This means that Redis is fast, but that it is also non-volatile.
  • The implementation of data structures emphasizes memory efficiency, so data structures inside Redis will likely use less memory compared to the same data structure modelled using a high-level programming language.
  • Redis offers a number of features that are natural to find in a database, like replication, tunable levels of durability, clustering, and high availability.

Another good example is to think of Redis as a more complex version of memcached, where the operations are not just SETs and GETs, but operations that work with complex data types like Lists, Sets, ordered data structures, and so forth.

If you want to know more, this is a list of selected starting points:

Building Redis

Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD. We support big endian and little endian architectures, and both 32 bit and 64 bit systems.

It may compile on Solaris derived systems (for instance SmartOS) but our support for this platform is best effort and Redis is not guaranteed to work as well as in Linux, OSX, and *BSD.

It is as simple as:

% make

To build with TLS support, you'll need OpenSSL development libraries (e.g. libssl-dev on Debian/Ubuntu) and run:

% make BUILD_TLS=yes

To build with systemd support, you'll need systemd development libraries (such as libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS) and run:

% make USE_SYSTEMD=yes

To append a suffix to Redis program names, use:

% make PROG_SUFFIX="-alt"

You can build a 32 bit Redis binary using:

% make 32bit

After building Redis, it is a good idea to test it using:

% make test

If TLS is built, running the tests with TLS enabled (you will need tcl-tls installed):

% ./utils/gen-test-certs.sh
% ./runtest --tls

Fixing build problems with dependencies or cached build options

Redis has some dependencies which are included in the deps directory. make does not automatically rebuild dependencies even if something in the source code of dependencies changes.

When you update the source code with git pull or when code inside the dependencies tree is modified in any other way, make sure to use the following command in order to really clean everything and rebuild from scratch:

% make distclean

This will clean: jemalloc, lua, hiredis, linenoise and other dependencies.

Also if you force certain build options like 32bit target, no C compiler optimizations (for debugging purposes), and other similar build time options, those options are cached indefinitely until you issue a make distclean command.

Fixing problems building 32 bit binaries

If after building Redis with a 32 bit target you need to rebuild it with a 64 bit target, or the other way around, you need to perform a make distclean in the root directory of the Redis distribution.

In case of build errors when trying to build a 32 bit binary of Redis, try the following steps:

  • Install the package libc6-dev-i386 (also try g++-multilib).
  • Try using the following command line instead of make 32bit: make CFLAGS="-m32 -march=native" LDFLAGS="-m32"

Allocator

Selecting a non-default memory allocator when building Redis is done by setting the MALLOC environment variable. Redis is compiled and linked against libc malloc by default, with the exception of jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

Monotonic clock

By default, Redis will build using the POSIX clock_gettime function as the monotonic clock source. On most modern systems, the internal processor clock can be used to improve performance. Cautions can be found here: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/

To build with support for the processor's internal instruction clock, use:

% make CFLAGS="-DUSE_PROCESSOR_CLOCK"

Verbose build

Redis will build with a user-friendly colorized output by default. If you want to see a more verbose output, use the following:

% make V=1

Running Redis

To run Redis with the default configuration, just type:

% cd src
% ./redis-server

If you want to provide your redis.conf, you have to run it using an additional parameter (the path of the configuration file):

% cd src
% ./redis-server /path/to/redis.conf

It is possible to alter the Redis configuration by passing parameters directly as options using the command line. Examples:

% ./redis-server --port 9999 --replicaof 127.0.0.1 6379
% ./redis-server /etc/redis/6379.conf --loglevel debug

All the options in redis.conf are also supported as options using the command line, with exactly the same name.

Running Redis with TLS:

Please consult the TLS.md file for more information on how to use Redis with TLS.

Playing with Redis

You can use redis-cli to play with Redis. Start a redis-server instance, then in another terminal try the following:

% cd src
% ./redis-cli
redis> ping
PONG
redis> set foo bar
OK
redis> get foo
"bar"
redis> incr mycounter
(integer) 1
redis> incr mycounter
(integer) 2
redis>

You can find the list of all the available commands at https://redis.io/commands.

Installing Redis

In order to install Redis binaries into /usr/local/bin, just use:

% make install

You can use make PREFIX=/some/other/directory install if you wish to use a different destination.

make install will just install binaries in your system, but will not configure init scripts and configuration files in the appropriate place. This is not needed if you just want to play a bit with Redis, but if you are installing it the proper way for a production system, we have a script that does this for Ubuntu and Debian systems:

% cd utils
% ./install_server.sh

Note: install_server.sh will not work on Mac OSX; it is built for Linux only.

The script will ask you a few questions and will setup everything you need to run Redis properly as a background daemon that will start again on system reboots.

You'll be able to stop and start Redis using the script named /etc/init.d/redis_<portnumber>, for instance /etc/init.d/redis_6379.

Code contributions

By contributing code to the Redis project in any form, including sending a pull request via GitHub, a code fragment or patch via private email or public discussion groups, you agree to release your code under the terms of the Redis Software Grant and Contributor License Agreement. Redis software contains contributions to the original Redis core project, which are owned by their contributors and licensed under the 3BSD license. Any copy of that license in this repository applies only to those contributions. Redis releases all Redis project versions from 7.4.x and thereafter under the RSALv2/SSPL dual-license as described in the LICENSE.txt file included in the Redis source distribution.

Please see the CONTRIBUTING.md file in this source distribution for more information. For security bugs and vulnerabilities, please see SECURITY.md.

Redis Trademarks

The purpose of a trademark is to identify the goods and services of a person or company without causing confusion. As the registered owner of its name and logo, Redis accepts certain limited uses of its trademarks but it has requirements that must be followed as described in its Trademark Guidelines available at: https://redis.com/legal/trademark-guidelines/.

Redis internals

If you are reading this README you are likely in front of a Github page or you just untarred the Redis distribution tar ball. In both the cases you are basically one step away from the source code, so here we explain the Redis source code layout, what is in each file as a general idea, the most important functions and structures inside the Redis server and so forth. We keep all the discussion at a high level without digging into the details since this document would be huge otherwise and our code base changes continuously, but a general idea should be a good starting point to understand more. Moreover most of the code is heavily commented and easy to follow.

Source code layout

The Redis root directory just contains this README, the Makefile which calls the real Makefile inside the src directory and an example configuration for Redis and Sentinel. You can find a few shell scripts that are used in order to execute the Redis, Redis Cluster and Redis Sentinel unit tests, which are implemented inside the tests directory.

Inside the root are the following important directories:

  • src: contains the Redis implementation, written in C.
  • tests: contains the unit tests, implemented in Tcl.
  • deps: contains libraries Redis uses. Everything needed to compile Redis is inside this directory; your system just needs to provide libc, a POSIX compatible interface and a C compiler. Notably deps contains a copy of jemalloc, which is the default allocator of Redis under Linux. Note that under deps there are also things which started with the Redis project, but for which the main repository is not redis/redis.

There are a few more directories but they are not very important for our goals here. We'll focus mostly on src, where the Redis implementation is contained, exploring what there is inside each file. The order in which files are exposed is the logical one to follow in order to disclose different layers of complexity incrementally.

Note: lately Redis was refactored quite a bit. Function names and file names have been changed, so you may find that this documentation reflects the unstable branch more closely. For instance, in Redis 3.0 the server.c and server.h files were named redis.c and redis.h. However the overall structure is the same. Keep in mind that all the new developments and pull requests should be performed against the unstable branch.

server.h

The simplest way to understand how a program works is to understand the data structures it uses. So we'll start from the main header file of Redis, which is server.h.

All the server configuration and in general all the shared state is defined in a global structure called server, of type struct redisServer. A few important fields in this structure are:

  • server.db is an array of Redis databases, where data is stored.
  • server.commands is the command table.
  • server.clients is a linked list of clients connected to the server.
  • server.master is a special client, the master, if the instance is a replica.

There are tons of other fields. Most fields are commented directly inside the structure definition.

Another important Redis data structure is the one defining a client. In the past it was called redisClient, now just client. The structure has many fields, here we'll just show the main ones:

struct client {
    int fd;
    sds querybuf;
    int argc;
    robj **argv;
    redisDb *db;
    int flags;
    list *reply;
    // ... many other fields ...
    char buf[PROTO_REPLY_CHUNK_BYTES];
}

The client structure defines a connected client:

  • The fd field is the client socket file descriptor.
  • argc and argv are populated with the command the client is executing, so that functions implementing a given Redis command can read the arguments.
  • querybuf accumulates the requests from the client, which are parsed by the Redis server according to the Redis protocol and executed by calling the implementations of the commands the client is executing.
  • reply and buf are dynamic and static buffers that accumulate the replies the server sends to the client. These buffers are incrementally written to the socket as soon as the file descriptor is writable.

As you can see in the client structure above, arguments in a command are described as robj structures. The following is the full robj structure, which defines a Redis object:

struct redisObject {
    unsigned type:4;
    unsigned encoding:4;
    unsigned lru:LRU_BITS; /* LRU time (relative to global lru_clock) or
                            * LFU data (least significant 8 bits frequency
                            * and most significant 16 bits access time). */
    int refcount;
    void *ptr;
};

Basically this structure can represent all the basic Redis data types like strings, lists, sets, sorted sets and so forth. The interesting thing is that it has a type field, so that it is possible to know what type a given object has, and a refcount, so that the same object can be referenced in multiple places without allocating it multiple times. Finally the ptr field points to the actual representation of the object, which might vary even for the same type, depending on the encoding used.

Redis objects are used extensively in the Redis internals, however in order to avoid the overhead of indirect accesses, recently in many places we just use plain dynamic strings not wrapped inside a Redis object.

server.c

This is the entry point of the Redis server, where the main() function is defined. The following are the most important steps in order to startup the Redis server.

  • initServerConfig() sets up the default values of the server structure.
  • initServer() allocates the data structures needed to operate, setup the listening socket, and so forth.
  • aeMain() starts the event loop which listens for new connections.

There are two special functions called periodically by the event loop:

  1. serverCron() is called periodically (according to server.hz frequency), and performs tasks that must be performed from time to time, like checking for timed out clients.
  2. beforeSleep() is called every time the event loop fired, Redis served a few requests, and is returning back into the event loop.

Inside server.c you can find code that handles other vital things of the Redis server:

  • call() is used in order to call a given command in the context of a given client.
  • activeExpireCycle() handles eviction of keys with a time to live set via the EXPIRE command.
  • performEvictions() is called when a new write command should be performed but Redis is out of memory according to the maxmemory directive.
  • The global variable redisCommandTable defines all the Redis commands, specifying the name of the command, the function implementing the command, the number of arguments required, and other properties of each command.

commands.c

This file is auto generated by utils/generate-command-code.py, the content is based on the JSON files in the src/commands folder. These are meant to be the single source of truth about the Redis commands, and all the metadata about them. These JSON files are not meant to be used by anyone directly, instead that metadata can be obtained via the COMMAND command.

networking.c

This file defines all the I/O functions with clients, masters and replicas (which in Redis are just special clients):

  • createClient() allocates and initializes a new client.
  • The addReply*() family of functions are used by command implementations in order to append data to the client structure, that will be transmitted to the client as a reply for a given command executed.
  • writeToClient() transmits the data pending in the output buffers to the client and is called by the writable event handler sendReplyToClient().
  • readQueryFromClient() is the readable event handler and accumulates data read from the client into the query buffer.
  • processInputBuffer() is the entry point in order to parse the client query buffer according to the Redis protocol. Once commands are ready to be processed, it calls processCommand() which is defined inside server.c in order to actually execute the command.
  • freeClient() deallocates, disconnects and removes a client.

aof.c and rdb.c

As you can guess from the names, these files implement the RDB and AOF persistence for Redis. Redis uses a persistence model based on the fork() system call in order to create a process with the same (shared) memory content of the main Redis process. This secondary process dumps the content of the memory on disk. This is used by rdb.c to create the snapshots on disk and by aof.c in order to perform the AOF rewrite when the append only file gets too big.

The implementation inside aof.c has additional functions in order to implement an API that allows commands to append new commands into the AOF file as clients execute them.

The call() function defined inside server.c is responsible for calling the functions that in turn will write the commands into the AOF.

db.c

Certain Redis commands operate on specific data types; others are general. Examples of generic commands are DEL and EXPIRE. They operate on keys and not on their values specifically. All those generic commands are defined inside db.c.

Moreover db.c implements an API in order to perform certain operations on the Redis dataset without directly accessing the internal data structures.

The most important functions inside db.c which are used in many command implementations are the following:

  • lookupKeyRead() and lookupKeyWrite() are used in order to get a pointer to the value associated to a given key, or NULL if the key does not exist.
  • dbAdd() and its higher level counterpart setKey() create a new key in a Redis database.
  • dbDelete() removes a key and its associated value.
  • emptyData() removes an entire single database or all the databases defined.

The rest of the file implements the generic commands exposed to the client.

object.c

The robj structure defining Redis objects was already described. Inside object.c there are all the functions that operate with Redis objects at a basic level, like functions to allocate new objects, handle the reference counting and so forth. Notable functions inside this file:

  • incrRefCount() and decrRefCount() are used in order to increment or decrement an object reference count. When it drops to 0 the object is finally freed.
  • createObject() allocates a new object. There are also specialized functions to allocate string objects having a specific content, like createStringObjectFromLongLong() and similar functions.

This file also implements the OBJECT command.

replication.c

This is one of the most complex files inside Redis, it is recommended to approach it only after getting a bit familiar with the rest of the code base. In this file there is the implementation of both the master and replica role of Redis.

One of the most important functions inside this file is replicationFeedSlaves() that writes commands to the clients representing replica instances connected to our master, so that the replicas can get the writes performed by the clients: this way their data set will remain synchronized with the one in the master.

This file also implements both the SYNC and PSYNC commands that are used in order to perform the first synchronization between masters and replicas, or to continue the replication after a disconnection.

Script

The script unit is composed of 3 units:

  • script.c - integration of scripts with Redis (commands execution, set replication/resp, ...)
  • script_lua.c - responsible to execute Lua code, uses script.c to interact with Redis from within the Lua code.
  • function_lua.c - contains the Lua engine implementation, uses script_lua.c to execute the Lua code.
  • functions.c - contains Redis Functions implementation (FUNCTION command), uses functions_lua.c if the function it wants to invoke needs the Lua engine.
  • eval.c - contains the eval implementation using script_lua.c to invoke the Lua code.

Other C files

  • t_hash.c, t_list.c, t_set.c, t_string.c, t_zset.c and t_stream.c contains the implementation of the Redis data types. They implement both an API to access a given data type, and the client command implementations for these data types.
  • ae.c implements the Redis event loop, it's a self contained library which is simple to read and understand.
  • sds.c is the Redis string library, check https://github.com/antirez/sds for more information.
  • anet.c is a library to use POSIX networking in a simpler way compared to the raw interface exposed by the kernel.
  • dict.c is an implementation of a non-blocking hash table which rehashes incrementally.
  • cluster.c implements the Redis Cluster. Probably a good read only after being very familiar with the rest of the Redis code base. If you want to read cluster.c make sure to read the Redis Cluster specification.

Anatomy of a Redis command

All the Redis commands are defined in the following way:

void foobarCommand(client *c) {
    printf("%s",c->argv[1]->ptr); /* Do something with the argument. */
    addReply(c,shared.ok); /* Reply something to the client. */
}

The command function is referenced by a JSON file, together with its metadata, see commands.c described above for details. The command flags are documented in the comment above the struct redisCommand in server.h. For other details, please refer to the COMMAND command. https://redis.io/commands/command/

After the command operates in some way, it returns a reply to the client, usually using addReply() or a similar function defined inside networking.c.

There are tons of command implementations inside the Redis source code that can serve as examples of actual commands implementations (e.g. pingCommand). Writing a few toy commands can be a good exercise to get familiar with the code base.

There are also many other files not described here, but it is useless to cover everything. We just want to help you with the first steps. Eventually you'll find your way inside the Redis code base :-)

Enjoy!

hiredis-py's People

Contributors

akarys42 avatar andymccurdy avatar badboy avatar chayim avatar drawoc avatar ifduyue avatar illia-v avatar jdufresne avatar mgorny avatar michael-grunder avatar michael-k avatar mrowl avatar not-a-robot[bot] avatar oranav avatar patricklucas avatar peter-conalgo avatar pfreixes avatar pietern avatar popravich avatar prokazov avatar reinerh avatar sbdchd avatar shadchin avatar stumpylog avatar swegener avatar thedrow avatar tobixx avatar un-def avatar yoav-steinberg avatar zalmane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hiredis-py's Issues

src/reader.c:18: error: initializer element is not constant

I'm running into this problem when I try to build hiredis-py:

(env)Debian-50-lenny-64-LAMP:/tmp# git clone git://github.com/pietern/hiredis-py.git hir
Initialized empty Git repository in /tmp/hir/.git/
remote: Counting objects: 259, done.
remote: Compressing objects: 100% (158/158), done.
remote: Total 259 (delta 122), reused 193 (delta 83)
Receiving objects: 100% (259/259), 34.07 KiB, done.
Resolving deltas: 100% (122/122), done.

(env)Debian-50-lenny-64-LAMP:/tmp# cd hir
(env)Debian-50-lenny-64-LAMP:/tmp/hir# git submodule init
Submodule 'vendor/hiredis' (git://github.com/antirez/hiredis.git) registered for path 'vendor/hiredis'
(env)Debian-50-lenny-64-LAMP:/tmp/hir# git submodule update
Initialized empty Git repository in /tmp/hir/vendor/hiredis/.git/
remote: Counting objects: 2025, done.
remote: Compressing objects: 100% (715/715), done.
remote: Total 2025 (delta 1346), reused 1928 (delta 1257)
Receiving objects: 100% (2025/2025), 370.63 KiB, done.
Resolving deltas: 100% (1346/1346), done.
Submodule path 'vendor/hiredis': checked out '857b2690afd8d9fbbb3472c948b74dd6cd6e8a95'

(env)Debian-50-lenny-64-LAMP:/tmp/hir# ll
total 60K
drwxr-xr-x  8 root root 4.0K 2012-05-27 20:41 .
drwxrwxrwt 13 root root 4.0K 2012-05-27 20:41 ..
drwxr-xr-x  2 root root 4.0K 2012-05-27 20:41 benchmark
-rw-r--r--  1 root root 1.5K 2012-05-27 20:41 COPYING
drwxr-xr-x  8 root root 4.0K 2012-05-27 20:42 .git
-rw-r--r--  1 root root   28 2012-05-27 20:41 .gitignore
-rw-r--r--  1 root root   96 2012-05-27 20:41 .gitmodules
drwxr-xr-x  2 root root 4.0K 2012-05-27 20:41 hiredis
-rw-r--r--  1 root root  157 2012-05-27 20:41 MANIFEST.in
-rw-r--r--  1 root root 4.0K 2012-05-27 20:41 README.md
-rwxr-xr-x  1 root root 1.4K 2012-05-27 20:41 setup.py
drwxr-xr-x  2 root root 4.0K 2012-05-27 20:41 src
drwxr-xr-x  2 root root 4.0K 2012-05-27 20:41 test
-rwxr-xr-x  1 root root  107 2012-05-27 20:41 test.py
drwxr-xr-x  3 root root 4.0K 2012-05-27 20:42 vendor

(env)Debian-50-lenny-64-LAMP:/tmp/hir# python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.5
creating build/lib.linux-x86_64-2.5/hiredis
copying hiredis/version.py -> build/lib.linux-x86_64-2.5/hiredis
copying hiredis/__init__.py -> build/lib.linux-x86_64-2.5/hiredis
running build_clib
building 'hiredis' library
creating build/temp.linux-x86_64-2.5
creating build/temp.linux-x86_64-2.5/vendor
creating build/temp.linux-x86_64-2.5/vendor/hiredis
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.linux-x86_64-2.5/vendor/hiredis/hiredis.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/net.c -o build/temp.linux-x86_64-2.5/vendor/hiredis/net.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/sds.c -o build/temp.linux-x86_64-2.5/vendor/hiredis/sds.o
ar -cr build/temp.linux-x86_64-2.5/libhiredis.a build/temp.linux-x86_64-2.5/vendor/hiredis/hiredis.o build/temp.linux-x86_64-2.5/vendor/hiredis/net.o build/temp.linux-x86_64-2.5/vendor/hiredis/sds.o
running build_ext
building 'hiredis.hiredis' extension
creating build/temp.linux-x86_64-2.5/src
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Isrc -Ivendor -I/usr/include/python2.5 -c src/reader.c -o build/temp.linux-x86_64-2.5/src/reader.o
src/reader.c:17: warning: implicit declaration of function โ€˜PyVarObject_HEAD_INITโ€™
src/reader.c:18: error: initializer element is not constant
src/reader.c:18: error: (near initialization for โ€˜hiredis_ReaderType.ob_refcntโ€™)
src/reader.c:18: error: expected โ€˜}โ€™ before string constant
src/reader.c: In function โ€˜createDecodedStringโ€™:
src/reader.c:71: warning: implicit declaration of function โ€˜PyBytes_FromStringAndSizeโ€™
src/reader.c:71: warning: assignment makes pointer from integer without a cast
src/reader.c:77: warning: assignment makes pointer from integer without a cast
src/reader.c: In function โ€˜freeObjectโ€™:
src/reader.c:136: warning: dereferencing โ€˜void *โ€™ pointer
src/reader.c:136: error: request for member โ€˜ob_refcntโ€™ in something not a structure or union
src/reader.c: In function โ€˜Reader_initโ€™:
src/reader.c:200: warning: implicit declaration of function โ€˜PyObject_Bytesโ€™
src/reader.c:200: warning: assignment makes pointer from integer without a cast
src/reader.c:205: warning: implicit declaration of function โ€˜PyBytes_Sizeโ€™
src/reader.c:206: warning: implicit declaration of function โ€˜PyBytes_AsStringโ€™
src/reader.c:206: warning: assignment makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1```

New 0.2.0 packages uploaded to PyPi

Sorry to open an issue but new packages for the 0.2.0 version have been pushed to pypi and we have checks on file hashes failing in CI.

Can this release be trusted?

Release latest version

Last version released was 2 years ago. Please release new version so we can use it in production environment.

Python 3.5.2 Build Fail

Using a virtualenv on Ubuntu.

python3-dev is currently installed on the system (all system-requirements are met, as far as the docs go).

Collecting hiredis (from aioredis)
  Using cached hiredis-0.2.0.tar.gz
Building wheels for collected packages: hiredis
  Running setup.py bdist_wheel for hiredis ... error
  Complete output from command /home/ubuntu/async/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-5ypx42mc/hiredis/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpox55b2qlpip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/hiredis
  copying hiredis/version.py -> build/lib.linux-x86_64-3.5/hiredis
  copying hiredis/__init__.py -> build/lib.linux-x86_64-3.5/hiredis
  running build_clib
  building 'hiredis_for_hiredis_py' library
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/vendor
  creating build/temp.linux-x86_64-3.5/vendor/hiredis
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -c vendor/hiredis/read.c -o build/temp.linux-x86_64-3.5/vendor/hiredis/read.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -c vendor/hiredis/sds.c -o build/temp.linux-x86_64-3.5/vendor/hiredis/sds.o
  x86_64-linux-gnu-gcc-ar rc build/temp.linux-x86_64-3.5/libhiredis_for_hiredis_py.a build/temp.linux-x86_64-3.5/vendor/hiredis/read.o build/temp.linux-x86_64-3.5/vendor/hiredis/sds.o
  running build_ext
  building 'hiredis.hiredis' extension
  creating build/temp.linux-x86_64-3.5/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Ivendor -I/usr/include/python3.5m -I/home/ubuntu/async/include/python3.5m -c src/reader.c -o build/temp.linux-x86_64-3.5/src/reader.o
  In file included from src/reader.h:4:0,
                   from src/reader.c:1:
  src/hiredis.h:4:20: fatal error: Python.h: No such file or directory
   #include <Python.h>
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for hiredis

Broken bdist_rpm

Hi,

I'm trying to build an RPM for hiredis 0.1.1 and it seems that this functionality is broken due to the .h files not being included in the MANIFEST. Adding these lines at the end of the file fixes the problem:

src/hiredis.h
src/reader.h
vendor/hiredis/hiredis.h
vendor/hiredis/fmacros.h
vendor/hiredis/net.h
vendor/hiredis/sds.h

easy_install hiredis # not work

C:\Users\...>easy_install hiredis
Searching for hiredis
Reading https://pypi.python.org/simple/hiredis/
Best match: hiredis 0.1.3
Downloading https://pypi.python.org/packages/source/h/hiredis/hiredis-0.1.3.tar.gz#md5=69a66903399d6a1e69f3a62e11d34d26
Processing hiredis-0.1.3.tar.gz
Writing c:\windows\temp\easy_install-_yzdqc\hiredis-0.1.3\setup.cfg
Running hiredis-0.1.3\setup.py -q bdist_egg --dist-dir c:\windows\temp\easy_install-_yzdqc\hiredis-0.1.3\egg-dist-tmp-4zqgsv
warning: no previously-included files found matching 'vendor\hiredis\example*'
warning: no previously-included files found matching 'vendor\hiredis\text*'
hiredis.c
vendor/hiredis/hiredis.c(35) : fatal error C1083: ะะต ัƒะดะฐะตั‚ัั ะพั‚ะบั€ั‹ั‚ัŒ ั„ะฐะนะป include: unistd.h: No suchfile or directory
error: DistutilsError('Setup script exited with error: CompileError(DistutilsExecError(\'command\\\'"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 9.0\\\\VC\\\\BIN\\\\cl.exe"\\\' failed with exit status 2\',),)',)

build hiredis failed with Python3.6.2 ubuntu:18.04 in docker

Hi,

can't install hiredis on ubuntu18.04 by Dockerfile
I have installed python3-dev
here is the error

Collecting hiredis (from aioredis==1.1.0->-r requirements.txt (line 4))
  Downloading https://files.pythonhosted.org/packages/1b/98/4766d85124b785ff1989ee1c79631a1b6ecfcb444ff39999a87877b2027e/hiredis-0.2.0.tar.gz (46kB)
Building wheels for collected packages: tornado, aiokafka, hiredis
  Running setup.py bdist_wheel for tornado: started
  Running setup.py bdist_wheel for tornado: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/29/8c/cf/6a5a8f6e35d877c0cb72b109d21c34981504897ce9a605e599
  Running setup.py bdist_wheel for aiokafka: started
  Running setup.py bdist_wheel for aiokafka: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/bd/6c/17/c2bd7b0a1bd623894cee46ef0c5743387d5b357a40f3b04d97
  Running setup.py bdist_wheel for hiredis: started
  Running setup.py bdist_wheel for hiredis: finished with status 'error'
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-cmwyelqa/hiredis/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp6zfo6hgopip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/hiredis
  copying hiredis/version.py -> build/lib.linux-x86_64-3.6/hiredis
  copying hiredis/__init__.py -> build/lib.linux-x86_64-3.6/hiredis
  running build_clib
  building 'hiredis_for_hiredis_py' library
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/vendor
  creating build/temp.linux-x86_64-3.6/vendor/hiredis
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -c vendor/hiredis/read.c -o build/temp.linux-x86_64-3.6/vendor/hiredis/read.o
  unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

hiredis causes pip to segfault

pip 9.0.1, Python 3.5.2, Ubuntu 16.04.2

mkvirtualenv -p $(which python3.5) testenv
pip install -I hiredis  # Works fine, the first time on a fresh virtualenv.
pip install -I hiredis  # segfaults if run in a virtualenv that already has hiredis.

PyPy Compatability

I was researching an issue a user reported to redis/redis-py#708 about some issues with hiredis and PyPy version 4.0.1 (and likely other versions of PyPy).

hiredis-py's feed method isn't able to accept bytearray objects running on PyPy. This test (https://github.com/redis/hiredis-py/blob/master/test/reader.py#L168) in hiredis-py's test suite fails running on PyPy testing this exact issue. It produces the following traceback:

Traceback (most recent call last):
  File "/Users/andy/hiredis-py/test/reader.py", line 170, in test_feed_bytearray
    self.reader.feed(bytearray(b"+ok\r\n"))
TypeError: must be convertible to a buffer, not bytearray

While trying to get hiredis-py's test suite to run on PyPy, I also found two other tests (https://github.com/redis/hiredis-py/blob/master/test/reader.py#L133-L139) that cause the test runner to segfault with the following output:

<andy@shockwave: ~hiredis-py (master)> python test.py
.................Fatal error in cpyext, CPython compatibility layer, calling PyList_CheckExact
Either report a bug or consider not using this particular extension
<OpErrFmt object at 0x1074432e0>
RPython traceback:
  File "pypy_module_cpyext_api_2.c", line 21254, in PyPyList_CheckExact
  File "pypy_module_cpyext_pyobject.c", line 2094, in BaseCpyTypedescr_realize
  File "pypy_objspace_std_objspace.c", line 4537, in allocate_instance__W_ObjectObject
  File "pypy_objspace_std_typeobject.c", line 4354, in W_TypeObject_check_user_subclass
Segmentation fault: 11

Permit errors='surrogateescape' and others

Relates to commit #82

This introduces the errors attribute, but it rejects all values apart from a hard-coded few. In particular, errors='surrogateescape' should be allowed (PEP 383, introduced in python 3.1) but is blocked.

However there are other defined error handlers, plus it's possible to add more dynamically with register_error.

Therefore I think it's better not to perform any validation here, but allow the provided value to be passed through to bytes.decode. Unknown values are rejected as soon as you try to use them.

>>> b'foo\xff'.decode("utf-8", "surrogateescape")
'foo\udcff'
>>> b'foo\xff'.decode("utf-8", "flurble")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown error handler name 'flurble'
>>>

Or, if you must validate before use, then use codecs.lookup_error instead of a hard-coded list.

>>> codecs.lookup_error("surrogateescape")
<built-in function surrogateescape>
>>> codecs.lookup_error("flurble")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown error handler name 'flurble'

Bump for python 3.9

Can we bump to 3.9?
It works fine when building from source and installing (hiredis 1.1.0).

build hiredis failed with Python3.5.0

Build hiredis with Python3.5.0, it will be error: "AssertionError"

More details as below:

....
  gcc -pthread -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ivendor -I/usr/local/python3/include/python3.5m -c src/hiredis.c -o build/temp.linux-x86_64-3.5/src/hiredis.o
  gcc -pthread -shared build/temp.linux-x86_64-3.5/src/reader.o build/temp.linux-x86_64-3.5/src/hiredis.o -Lbuild/temp.linux-x86_64-3.5 -lhiredis_for_hiredis_py -o build/lib.linux-x86_64-3.5/hiredis/hiredis.cpython-35m-x86_64-linux-gnu.so
  installing to build/bdist.linux-x86_64/wheel
  running install
  running install_lib
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel/hiredis
  copying build/lib.linux-x86_64-3.5/hiredis/hiredis.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel/hiredis
  copying build/lib.linux-x86_64-3.5/hiredis/__init__.py -> build/bdist.linux-x86_64/wheel/hiredis
  copying build/lib.linux-x86_64-3.5/hiredis/version.py -> build/bdist.linux-x86_64/wheel/hiredis
  running install_egg_info
  running egg_info
  writing dependency_links to hiredis.egg-info/dependency_links.txt
  writing hiredis.egg-info/PKG-INFO
  writing top-level names to hiredis.egg-info/top_level.txt
  warning: manifest_maker: standard file '-c' not found

  reading manifest file 'hiredis.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no previously-included files found matching 'vendor/hiredis/example*'
  warning: no previously-included files found matching 'vendor/hiredis/text*'
  writing manifest file 'hiredis.egg-info/SOURCES.txt'
  Copying hiredis.egg-info to build/bdist.linux-x86_64/wheel/hiredis-0.2.0-py3.5.egg-info
  running install_scripts
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-z8jh6ss0/hiredis/setup.py", line 81, in <module>
      'Topic :: Software Development',
    File "/usr/local/python3/lib/python3.5/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/python3/lib/python3.5/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/local/python3/lib/python3.5/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/mnt/env3/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 213, in run
      archive_basename = self.get_archive_basename()
    File "/mnt/env3/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 161, in get_archive_basename
      impl_tag, abi_tag, plat_tag = self.get_tag()
    File "/mnt/env3/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 155, in get_tag
      assert tag == supported_tags[0]
  AssertionError

  ----------------------------------------
  Failed building wheel for hiredis
Failed to build hiredis

Installation error - can't find Microsoft SDKS/.../lib

Hi. I'm trying to install hiredis-py but I'm getting this issue:

error: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\lib'

In the specified folder (v8.1) I only have a folder called ExtensionSDKs. I couldn't find a reference for needing a Microsoft SDK anywhere here. Am I doing something wrong?

Thanks in advance.

build_ext: cannot find -lhiredis_for_hiredis_py

Hi,

pip install hiredis --global-option=build_ext fails for me on both Ubuntu and CentOS.

I understand that hiredis_for_hiredis_py should refer to files in vendor/hiredis/? Am I doing something wrong?

Thanks!

Performance question

Due to some benchmarking and slowness issues we see:

  1. Does Hiredis prep the request and only then transmit to Redis server or does it start the session and stream data as we go?

  2. If i have a slow connection, will Redis get slowness because it takes a lot of time to pull the results / send the request (like zadd 40K records)

Installation on Windows

I'm having trouble getting the installation to work on Windows 10. Based on this post it appears to work but I'm getting the following error:

C:\>easy_install hiredis
Searching for hiredis
Reading https://pypi.python.org/simple/hiredis/
Downloading https://pypi.python.org/packages/1b/98/4766d85124b785ff1989ee1c79631a1b6ecfcb444ff39999a87877b2027e/hiredis-0.2.0.tar.gz#md5=b410cf2f2062d87ab841c33d8345761e
Best match: hiredis 0.2.0
Processing hiredis-0.2.0.tar.gz
Writing C:\Users\Dave\AppData\Local\Temp\easy_install-bmse4iwn\hiredis-0.2.0\setup.cfg
Running hiredis-0.2.0\setup.py -q bdist_egg --dist-dir C:\Users\Dave\AppData\Local\Temp\easy_install-bmse4iwn\hiredis-0.2.0\egg-dist-tmp-osh112zo
warning: no previously-included files found matching 'vendor\hiredis\example*'
warning: no previously-included files found matching 'vendor\hiredis\text*'
error: Setup script exited with error: INCLUDE environment variable is empty

What value do I need to set the INCLUDE environment variable to?

I install it with pypy1.9

because PyObject_Bytes is PyObject_Str alias.
so i replace PyObject_Bytes With PyObject_Str in reader.c on line 200.
and update pypy1.9 distribution to pypy 2.0x distribution.
then it's ok.

Update README for Python 3

The README currently recommends the python-dev apt package to get the development headers. That's for Python 2, though. For Python 3 you need python3-dev. Perhaps instead:

"On Ubuntu/Debian systems, install them with apt-get install python-dev or apt-get install python3-dev.

compialtion error on Ubuntu 11.04 64 bit

$sudo pip install hiredis --upgrade

sudo pip install hiredis --upgrade
Downloading/unpacking hiredis
Running setup.py egg_info for package hiredis

Installing collected packages: hiredis
Running setup.py install for hiredis
building 'hiredis' library
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/hiredis.o
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/net.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/net.o
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/sds.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o
ar rc build/temp.linux-x86_64-2.7/libhiredis.a build/temp.linux-x86_64-2.7/vendor/hiredis/hiredis.o build/temp.linux-x86_64-2.7/vendor/hiredis/net.o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o
building 'hiredis.hiredis' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Isrc -Ivendor -I/usr/include/python2.7 -c src/hiredis.c -o build/temp.linux-x86_64-2.7/src/hiredis.o
In file included from src/hiredis.c:1:0:
src/hiredis.h:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools;file='/home/salimane/htdocs/7ksns/trunk/build/hiredis/setup.py';execfile(file)" install --single-version-externally-managed --record /tmp/pip-lmiuw4-record/install-record.txt:
running install

running build

running build_py

copying hiredis/init.py -> build/lib.linux-x86_64-2.7/hiredis

copying hiredis/version.py -> build/lib.linux-x86_64-2.7/hiredis

running build_clib

building 'hiredis' library

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/hiredis.o

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/net.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/net.o

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ivendor/hiredis -c vendor/hiredis/sds.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o

ar rc build/temp.linux-x86_64-2.7/libhiredis.a build/temp.linux-x86_64-2.7/vendor/hiredis/hiredis.o build/temp.linux-x86_64-2.7/vendor/hiredis/net.o build/temp.linux-x86_64-2.7/vendor/hiredis/sds.o

running build_ext

building 'hiredis.hiredis' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Isrc -Ivendor -I/usr/include/python2.7 -c src/hiredis.c -o build/temp.linux-x86_64-2.7/src/hiredis.o

In file included from src/hiredis.c:1:0:

src/hiredis.h:4:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1


Command /usr/bin/python -c "import setuptools;file='/home/salimane/htdocs/7ksns/trunk/build/hiredis/setup.py';execfile(file)" install --single-version-externally-managed --record /tmp/pip-lmiuw4-record/install-record.txt failed with error code 1
Storing complete log in /home/salimane/.pip/pip.log

New maintainer needed

I have neither the time nor the energy to fulfil the maintainer role here.
I failed to spend enough time in the past and haven't pushed out a release in nearly 3 years.

If anyone is actively using this project and wants to take over, please reach me over email.

Wrong submodules

Hiredis repo is moved to github.com/redis/hiredis. Please update submodules!

Memory leak when querying large dataset

I query around 500 MB data from Redis on frequent basis. When I don't add hiredis, everything works fine but when hiredis is installed, there occurs a memory leak which eventually leads to process crash.

Warnings when installing

Installing on Linux (Ubuntu 16.04) under Python3.6 and using easy_install gives these warnings, but still seems to work.

Searching for hiredis
Reading https://pypi.python.org/simple/hiredis/
Downloading https://pypi.python.org/packages/1b/98/4766d85124b785ff1989ee1c79631a1b6ecfcb444ff39999a87877b2027e/hiredis-0.2.0.tar.gz#md5=b410cf2f2062d87ab841c33d8345761e
Best match: hiredis 0.2.0
Processing hiredis-0.2.0.tar.gz
Writing /tmp/easy_install-iethl5pn/hiredis-0.2.0/setup.cfg
Running hiredis-0.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-iethl5pn/hiredis-0.2.0/egg-dist-tmp-sk0axbvv
- warning: no previously-included files found matching 'vendor/hiredis/example*'
- warning: no previously-included files found matching 'vendor/hiredis/text*'
- zip_safe flag not set; analyzing archive contents...
- hiredis.__pycache__.hiredis.cpython-36: module references __file__
creating /usr/local/lib/python3.6/dist-packages/hiredis-0.2.0-py3.6-linux-x86_64.egg
Extracting hiredis-0.2.0-py3.6-linux-x86_64.egg to /usr/local/lib/python3.6/dist-packages
Adding hiredis 0.2.0 to easy-install.pth file
Installed /usr/local/lib/python3.6/dist-packages/hiredis-0.2.0-py3.6-linux-x86_64.egg
Processing dependencies for hiredis

UnicodeDecodeError in setup.py

Problem description

Cannot install hiredis on Windows.

Steps to reproduce

  1. Install Python
  2. Run:
py -3.8 -m pip install hiredis

Actual result

C:\>py -3.8 -m pip install hiredis
Collecting hiredis
  Using cached https://files.pythonhosted.org/packages/9e/e0/c160dbdff032ffe68e4b3c576cba3db22d8ceffc9513ae63368296d1bcc8/hiredis-1.0.0.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'C:\Python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-rrjljd7j\\hiredis\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-rrjljd7j\\hiredis\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-install-rrjljd7j\hiredis\pip-egg-info'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-rrjljd7j\hiredis\
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-rrjljd7j\hiredis\setup.py", line 22, in <module>
        long_description=open('README.md', 'r').read(),
      File "C:\Python38\lib\encodings\cp1251.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 2251: character maps to <undefined>
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Expected result

No errors.

Additional information

hiredis 1.0.0, 0.3.1, 0.3.0 are affected. hiredis 0.2.0 is not affected.

Capture status replies.

At the moment status messages (like OK) are just returned as bytes.

I need the parser to distinguish between received bytes and status messages (prefixed with a '+' sign.)

Any way to do this?

Thanks

(It's for asyncio-redis.)

Can't build on macosx 10.7

Hi! I'm getting trouble installing package on Leon. Or I'd better open this issue on main hiredis repo?
....
Running setup.py install for hiredis
building 'hiredis' library
/Developer/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.macosx-10.7-x86_64-2.7/vendor/hiredis/hiredis.o
vendor/hiredis/hiredis.c:691:21: error: second argument to 'va_arg' is of incomplete type 'void'
va_arg(ap,void);
^~~~~~~~~~~~~~~
/Developer/usr/bin/../lib/clang/3.0/include/stdarg.h:35:50: note: instantiated from:
#define va_arg(ap, type) builtin_va_arg(ap, type)
^
vendor/hiredis/hiredis.c:691:31: note: instantiated from:
va_arg(ap,void);
^~~~
1 error generated.
error: command '/Developer/usr/bin/clang' failed with exit status 1
Complete output from command /Users/demon/Work/sportlook.ru/env/bin/python -c "import setuptools;__file
='/Users/demon/Work/sportlook.ru/env/build/hiredis/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /var/folders/s5/3z_j0lyx3r9__09nfn7vb7wh0000gn/T/pip-4asypi-record/install-record.txt --install-headers /Users/demon/Work/sportlook.ru/env/bin/../include/site/python2.7:
running install

running build

running build_py

creating build

creating build/lib.macosx-10.7-x86_64-2.7

creating build/lib.macosx-10.7-x86_64-2.7/hiredis

copying hiredis/init.py -> build/lib.macosx-10.7-x86_64-2.7/hiredis

copying hiredis/version.py -> build/lib.macosx-10.7-x86_64-2.7/hiredis

running build_clib

building 'hiredis' library

creating build/temp.macosx-10.7-x86_64-2.7

creating build/temp.macosx-10.7-x86_64-2.7/vendor

creating build/temp.macosx-10.7-x86_64-2.7/vendor/hiredis

/Developer/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.macosx-10.7-x86_64-2.7/vendor/hiredis/hiredis.o

vendor/hiredis/hiredis.c:691:21: error: second argument to 'va_arg' is of incomplete type 'void'

                va_arg(ap,void);

                ^~~~~~~~~~~~~~~

/Developer/usr/bin/../lib/clang/3.0/include/stdarg.h:35:50: note: instantiated from:

define va_arg(ap, type) __builtin_va_arg(ap, type)

                                             ^

vendor/hiredis/hiredis.c:691:31: note: instantiated from:

                va_arg(ap,void);

                          ^~~~

1 error generated.

error: command '/Developer/usr/bin/clang' failed with exit status 1


Command /Users/demon/Work/sportlook.ru/env/bin/python -c "import setuptools;file='/Users/demon/Work/sportlook.ru/env/build/hiredis/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /var/folders/s5/3z_j0lyx3r9__09nfn7vb7wh0000gn/T/pip-4asypi-record/install-record.txt --install-headers /Users/demon/Work/sportlook.ru/env/bin/../include/site/python2.7 failed with error code 1
Storing complete log in /Users/demon/.pip/pip.log

Python 3 bug: sometimes the response to DEL is 'OK'

Hi !

I'm porting my code base to python 3, and just faced this issue:

  File "/my-env/lib/python3.5/site-packages/redis/client.py", line 842, in delete
    return self.execute_command('DEL', *names)
  File "/my-env/lib/python3.5/site-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/my-env/lib/python3.5/site-packages/redis/client.py", line 588, in parse_response
    return self.response_callbacks[command_name](response, **options)
ValueError: invalid literal for int() with base 10: b'OK'

This DEL command is run among multiple pipelines.
It happens for both PythonParser and HiredisParser.

If you need more details, I can try to isolate the succession of commands that fail.

Thanks!

Can't install in virtualenv on Ubuntu 11.10 64 bit (Error: None)

I can't install hiredis (only) in virtualenv, no problems when installed globally :(

(TICKETS)ju@Ubuntu-VirtualBox:/usr/local/pythonenv$ sudo pip install hiredis -E TICKETS

Downloading/unpacking hiredis
  Running setup.py egg_info for package hiredis

Installing collected packages: hiredis
  Running setup.py install for hiredis
    error: None
    Complete output from command /usr/local/pythonenv/TICKETS/bin/python -c "import setuptools;__file__='/usr/local/pythonenv/TICKETS/build/hiredis/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dn9RxE-record/install-record.txt --install-headers /usr/local/pythonenv/TICKETS/include/site/python2.7:
    running install

running build

running build_py

running build_clib

error: None

----------------------------------------
Command /usr/local/pythonenv/TICKETS/bin/python -c "import setuptools;__file__='/usr/local/pythonenv/TICKETS/build/hiredis/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dn9RxE-record/install-record.txt --install-headers /usr/local/pythonenv/TICKETS/include/site/python2.7 failed with error code 1
Storing complete log in /home/ju/.pip/pip.log

bdist_rpm doesn't work

I tried creating an RPM and installing it on CentOS 6, but I am getting the following error after installing:

>>> import hiredis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "hiredis/__init__.py", line 1, in <module>
    from .hiredis import Reader, HiredisError, ProtocolError, ReplyError
ImportError: No module named hiredis

Steps to reproduce:

$ git clone https://github.com/redis/hiredis-py
$ cd hiredis-py
$ git submodule update --init --recursive
$ python setup.py bdist_rpm
$ rpm -ivh dist/hiredis-0.2.0-1.x86_64.rpm

The version of python is 2.6.6 and setuptools 0.6.

easy_install hiredis # not work without `python-dev`

root@lucid32:~/hi4# easy_install hiredis
Searching for hiredis
Reading http://pypi.python.org/simple/hiredis/
Best match: hiredis 0.1.3
Downloading https://pypi.python.org/packages/source/h/hiredis/hiredis-0.1.3.tar.gz#md5=69a66903399d6a1e69f3a62e11d34d26
Processing hiredis-0.1.3.tar.gz
Running hiredis-0.1.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Nvvs5R/hiredis-0.1.3/egg-dist-tmp-uVfMb7
warning: no previously-included files found matching 'vendor/hiredis/example*'
warning: no previously-included files found matching 'vendor/hiredis/text*'
In file included from src/reader.h:4,
                 from src/reader.c:2:
src/hiredis.h:4:20: error: Python.h: No such file or directory
In file included from src/reader.h:4,
                 from src/reader.c:2:
src/hiredis.h:20: error: expected specifier-qualifier-list before 'PyObject'
src/hiredis.h:33: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
In file included from src/reader.c:2:
src/reader.h:7: error: expected specifier-qualifier-list before 'PyObject_HEAD'
src/reader.h:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'hiredis_ReaderType'
src/reader.c:5: error: expected declaration specifiers or '...' before 'PyObject'
src/reader.c:5: error: expected declaration specifiers or '...' before 'PyObject'
src/reader.c:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/reader.c:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/reader.c:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/reader.c:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'hiredis_ReaderMethods'
src/reader.c:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'hiredis_ReaderType'
src/reader.c:57: error: expected declaration specifiers or '...' before 'PyObject'
src/reader.c: In function 'tryParentize':
src/reader.c:58: error: 'PyObject' undeclared (first use in this function)
src/reader.c:58: error: (Each undeclared identifier is reported only once
src/reader.c:58: error: for each function it appears in.)
src/reader.c:58: error: 'parent' undeclared (first use in this function)
src/reader.c:60: error: expected expression before ')' token
src/reader.c:62: warning: implicit declaration of function 'PyList_SET_ITEM'
src/reader.c:62: error: 'obj' undeclared (first use in this function)
src/reader.c: At top level:
src/reader.c:67: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/reader.c:100: error: expected ')' before '*' token
src/reader.c: In function 'createStringObject':
src/reader.c:113: error: 'PyObject' undeclared (first use in this function)
src/reader.c:113: error: 'obj' undeclared (first use in this function)
src/reader.c:116: warning: implicit declaration of function 'createError'
src/reader.c:116: error: 'hiredis_ReaderObject' has no member named 'replyErrorClass'
src/reader.c:118: warning: implicit declaration of function 'createDecodedString'
src/reader.c:121: error: too many arguments to function 'tryParentize'
src/reader.c: In function 'createArrayObject':
src/reader.c:125: error: 'PyObject' undeclared (first use in this function)
src/reader.c:125: error: 'obj' undeclared (first use in this function)
src/reader.c:126: warning: implicit declaration of function 'PyList_New'
src/reader.c:127: error: too many arguments to function 'tryParentize'
src/reader.c: In function 'createIntegerObject':
src/reader.c:131: error: 'PyObject' undeclared (first use in this function)
src/reader.c:131: error: 'obj' undeclared (first use in this function)
src/reader.c:132: warning: implicit declaration of function 'PyLong_FromLongLong'
src/reader.c:133: error: too many arguments to function 'tryParentize'
src/reader.c: In function 'createNilObject':
src/reader.c:137: error: 'PyObject' undeclared (first use in this function)
src/reader.c:137: error: 'obj' undeclared (first use in this function)
src/reader.c:137: error: 'Py_None' undeclared (first use in this function)
src/reader.c:138: warning: implicit declaration of function 'Py_INCREF'
src/reader.c:139: error: too many arguments to function 'tryParentize'
src/reader.c: In function 'freeObject':
src/reader.c:143: warning: implicit declaration of function 'Py_XDECREF'
src/reader.c: In function 'Reader_dealloc':
src/reader.c:155: error: 'hiredis_ReaderObject' has no member named 'reader'
src/reader.c:156: error: 'hiredis_ReaderObject' has no member named 'encoding'
src/reader.c:157: warning: implicit declaration of function 'free'
src/reader.c:157: warning: incompatible implicit declaration of built-in function 'free'
src/reader.c:157: error: 'hiredis_ReaderObject' has no member named 'encoding'
src/reader.c:159: error: 'PyObject' undeclared (first use in this function)
src/reader.c:159: error: expected expression before ')' token
src/reader.c:159: error: expected expression before ')' token
src/reader.c: At top level:
src/reader.c:162: error: expected ')' before '*' token
src/reader.c:177: error: expected declaration specifiers or '...' before 'PyObject'
src/reader.c:177: error: expected declaration specifiers or '...' before 'PyObject'
src/reader.c: In function 'Reader_init':
src/reader.c:179: error: 'PyObject' undeclared (first use in this function)
src/reader.c:179: error: 'protocolErrorClass' undeclared (first use in this function)
src/reader.c:180: error: 'replyErrorClass' undeclared (first use in this function)
src/reader.c:181: error: 'encodingObj' undeclared (first use in this function)
src/reader.c:183: warning: implicit declaration of function 'PyArg_ParseTupleAndKeywords'
src/reader.c:183: error: 'args' undeclared (first use in this function)
src/reader.c:183: error: 'kwds' undeclared (first use in this function)
src/reader.c:188: warning: implicit declaration of function '_Reader_set_exception'
src/reader.c:188: error: 'hiredis_ReaderObject' has no member named 'protocolErrorClass'
src/reader.c:192: error: 'hiredis_ReaderObject' has no member named 'replyErrorClass'
src/reader.c:196: error: 'encbytes' undeclared (first use in this function)
src/reader.c:200: warning: implicit declaration of function 'PyUnicode_Check'
src/reader.c:201: warning: implicit declaration of function 'PyUnicode_AsASCIIString'
src/reader.c:203: warning: implicit declaration of function 'PyObject_Bytes'
src/reader.c:208: warning: implicit declaration of function 'PyBytes_Size'
src/reader.c:209: warning: implicit declaration of function 'PyBytes_AsString'
src/reader.c:210: error: 'hiredis_ReaderObject' has no member named 'encoding'
src/reader.c:210: warning: implicit declaration of function 'malloc'
src/reader.c:210: warning: incompatible implicit declaration of built-in function 'malloc'
src/reader.c:211: warning: implicit declaration of function 'memcpy'
src/reader.c:211: warning: incompatible implicit declaration of built-in function 'memcpy'
src/reader.c:211: error: 'hiredis_ReaderObject' has no member named 'encoding'
src/reader.c:212: error: 'hiredis_ReaderObject' has no member named 'encoding'
src/reader.c:213: warning: implicit declaration of function 'Py_DECREF'
src/reader.c: At top level:
src/reader.c:219: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/reader.c:240: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
src/reader.c:251: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
error: Setup script exited with error: command 'gcc' failed with exit status 1

Please add to README.md this line:

apt-get install python-dev

Can't install hiredis with pip on CentOs 7

I already installed python34-devel,

[vagrant@localhost vagrant]$ sudo pip install hiredis
Collecting hiredis
  Using cached hiredis-0.2.0.tar.gz
Installing collected packages: hiredis
  Running setup.py install for hiredis ... error
    Complete output from command /usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-DJcC2F/hiredis/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-cYj42J-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/hiredis
    copying hiredis/version.py -> build/lib.linux-x86_64-2.7/hiredis
    copying hiredis/__init__.py -> build/lib.linux-x86_64-2.7/hiredis
    running build_clib
    building 'hiredis_for_hiredis_py' library
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/vendor
    creating build/temp.linux-x86_64-2.7/vendor/hiredis
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c vendor/hiredis/read.c -o build/temp.linux-x86_64-2.7/vendor/hiredis/read.o
    unable to execute gcc: No such file or directory
    error: command 'gcc' failed with exit status 1

Binary hiredis-py 0.1.1 incompatibility with hiredis-0.11.0

I've built hiredis-py 0.1.1 on Fedora 19 and found the following code snippet would segfault:

import hiredis
reader = hiredis.Reader()
reader.feed('+PONG\r\n')
response = reader.gets()
print response

I noticed that it would only segfault when hiredis-py was dynamically linked against the system hiredis which would occur when the Fedora hiredis-devel package was installed:

$ ldd /lib64/python2.7/site-packages/hiredis/hiredis.so | grep hiredis
    libhiredis.so.0.10 => /lib64/libhiredis.so.0.10 (0x00007f7ee22ee000)

Note that Fedora 19 is shipping hiredis-0.11.0 and it appears the upstream hiredis package did not bump their SONAME which is part of the problem.

After debugging I've found the cause of the crash is that the following upstream upstream hiredis commits changed the size of struct redisReader:
redis/hiredis@51ab89d Max depth of multi-bulk reply moved from 2 to 7.
redis/hiredis@7f09505 Configurable reader max idle buffer size.

Changing the size of struct redisReader causes hiredis-py to fail to initialize the redisReplyObjectFunctions *fn since it is now in a different memory address and thus the default hiredis functions are called instead of the hiredis-py versions.

As I mentioned previously the real problem here is that hiredis broke their ABI between 0.10.0 and 0.11.0 and did not bump their SONAME. The secondary problem is that hiredis-py includes its own hiredis.h which means that simply rebuilding on Fedora 19 doesn't solve the problem. The only work around that I have is to rebuild hiredis-py without the hiredis-devel package installed which causes hiredis-py to build its own included version of hiredis and statically link against that version.

Can't install inside a virtualenv

Hi there,

When I install hiredis for global environment, it works, but when I try to install it inside a virtualenv it gives me this error:

Downloading/unpacking hiredis
Running setup.py egg_info for package hiredis
running egg_info
writing pip-egg-info/hiredis.egg-info/PKG-INFO
writing top-level names to pip-egg-info/hiredis.egg-info/top_level.txt
writing dependency_links to pip-egg-info/hiredis.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found

reading manifest file 'pip-egg-info/hiredis.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/hiredis.egg-info/SOURCES.txt'

Installing collected packages: hiredis
Running setup.py install for hiredis
Running command /home/diogo/Envs/bruce/bin/python2.7 -c "import setuptools;file='/home/diogo/Envs/bruce/build/hiredis/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-NnXIVL-record/install-record.txt --install-headers /home/diogo/Envs/bruce/include/site/python2.7
running install
running build
running build_py
copying hiredis/version.py -> build/lib.linux-x86_64-2.7/hiredis
copying hiredis/init.py -> build/lib.linux-x86_64-2.7/hiredis
running build_clib
error: None
Complete output from command /home/diogo/Envs/bruce/bin/python2.7 -c "import setuptools;file='/home/diogo/Envs/bruce/build/hiredis/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-NnXIVL-record/install-record.txt --install-headers /home/diogo/Envs/bruce/include/site/python2.7:
running install

running build

running build_py

copying hiredis/version.py -> build/lib.linux-x86_64-2.7/hiredis

copying hiredis/init.py -> build/lib.linux-x86_64-2.7/hiredis

running build_clib

error: None


Command /home/diogo/Envs/bruce/bin/python2.7 -c "import setuptools;file='/home/diogo/Envs/bruce/build/hiredis/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-NnXIVL-record/install-record.txt --install-headers /home/diogo/Envs/bruce/include/site/python2.7 failed with error code 1
Exception information:
Traceback (most recent call last):
File "/home/diogo/Envs/bruce/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg/pip/basecommand.py", line 126, in main
self.run(options, args)
File "/home/diogo/Envs/bruce/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg/pip/commands/install.py", line 228, in run
requirement_set.install(install_options, global_options)
File "/home/diogo/Envs/bruce/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg/pip/req.py", line 1100, in install
requirement.install(install_options, global_options)
File "/home/diogo/Envs/bruce/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg/pip/req.py", line 572, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/home/diogo/Envs/bruce/lib/python2.7/site-packages/pip-1.0.1-py2.7.egg/pip/init.py", line 255, in call_subprocess
% (command_desc, proc.returncode))
InstallationError: Command /home/diogo/Envs/bruce/bin/python2.7 -c "import setuptools;file='/home/diogo/Envs/bruce/build/hiredis/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-NnXIVL-record/install-record.txt --install-headers /home/diogo/Envs/bruce/include/site/python2.7 failed with error code 1

Can anyone help me on this?

Thanks a lot,

Diogo

Got "TypeError: must be convertible to a buffer, not bytearray" in PyPy

PyPy version: 4.0.1 with GCC 4.8.4 on linux2
System: Ubuntu 15.04 x86 64bit
Error line: ./site-packages/redis/connection.py line 359 self._reader.feed(self._buffer, 0, bufflen)

Find where define attribute _reader: line 313 self._reader = hiredis.Reader(**kwargs), so I think this might be a hiredis problem.
self._buffer's type: line 292 self._buffer = bytearray(socket_read_size)

I tried to change self._reader's type, do like this: self._reader.feed(buffer(self._buffer), 0, bufflen), but if i do this, process would crash.

Now I just move hiredis out, redis clients works no problem.

Installing hiredis fails after upgrading to Python 3.8

While installing hiredis after upgrading to Python 3.8, I am getting error saying error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2.
I tried reinstalling Visual Studio Build tools again even after i had it installed (version 14.23) but it didn't worked. Following is the full traceback:

C:\Users\thecosmos>pip install hiredis
Collecting hiredis
  Using cached https://files.pythonhosted.org/packages/9e/e0/c160dbdff032ffe68e4b3c576cba3db22d8ceffc9513ae63368296d1bcc8/hiredis-1.0.0.tar.gz
Installing collected packages: hiredis
    Running setup.py install for hiredis ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\thecosmos\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\thecosmos\\AppData\\Local\\Temp\\pip-install-uq9svr1x\\hiredis\\setup.py'"'"'; __file__='"'"'C:\\Users\\thecosmos\\AppData\\Local\\Temp\\pip-install-uq9svr1x\\hiredis\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\thecosmos\AppData\Local\Temp\pip-record-furdsc9j\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\thecosmos\AppData\Local\Temp\pip-install-uq9svr1x\hiredis\
    Complete output (11 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    creating build\lib.win-amd64-3.8\hiredis
    copying hiredis\version.py -> build\lib.win-amd64-3.8\hiredis
    copying hiredis\__init__.py -> build\lib.win-amd64-3.8\hiredis
    running build_ext
    building 'hiredis.hiredis' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\thecosmos\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\thecosmos\\AppData\\Local\\Temp\\pip-install-uq9svr1x\\hiredis\\setup.py'"'"'; __file__='"'"'C:\\Users\\thecosmos\\AppData\\Local\\Temp\\pip-install-uq9svr1x\\hiredis\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\thecosmos\AppData\Local\Temp\pip-record-furdsc9j\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

build hiredis failed with Python3.6.2 macOS

Hi,

can't install hiredis which fails at building wheel. Please advise.

wheel 0.29.0 py36h3597b6d_1

pip install hiredis
Collecting hiredis
  Using cached hiredis-0.2.0.tar.gz
Building wheels for collected packages: hiredis
  Running setup.py bdist_wheel for hiredis ... error
  Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/yy/_lh_xrrx7r92m999snj4dt1nvs_f1b/T/pip-build-im8m7cxh/hiredis/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/yy/_lh_xrrx7r92m999snj4dt1nvs_f1b/T/tmplgz4f1q6pip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.6
  creating build/lib.macosx-10.9-x86_64-3.6/hiredis
  copying hiredis/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/hiredis
  copying hiredis/version.py -> build/lib.macosx-10.9-x86_64-3.6/hiredis
  running build_clib
  building 'hiredis_for_hiredis_py' library
  creating build/temp.macosx-10.9-x86_64-3.6
  creating build/temp.macosx-10.9-x86_64-3.6/vendor
  creating build/temp.macosx-10.9-x86_64-3.6/vendor/hiredis
  /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -c vendor/hiredis/read.c -o build/temp.macosx-10.9-x86_64-3.6/vendor/hiredis/read.o
  /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -c vendor/hiredis/sds.c -o build/temp.macosx-10.9-x86_64-3.6/vendor/hiredis/sds.o
  x86_64-apple-darwin13.4.0-ar rc build/temp.macosx-10.9-x86_64-3.6/libhiredis_for_hiredis_py.a build/temp.macosx-10.9-x86_64-3.6/vendor/hiredis/read.o build/temp.macosx-10.9-x86_64-3.6/vendor/hiredis/sds.o
  unable to execute 'x86_64-apple-darwin13.4.0-ar': No such file or directory
  error: command 'x86_64-apple-darwin13.4.0-ar' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for hiredis

Request: RESP 3 support

hi, i am the author of one of the python redis implementations, and i am currently working on implementing resp3 in my fallback parser.

are there already plans to support RESP 3? if yes how are you planning to implement protocol switching?

this is somehow important because with RESP 3 parsers/clients are expected to return programming language native responses, like dicts, lists or sets.

since i mimic the api of hiredis-py, i would think it would be nice if there is a function to tell the parser to switch protocols.

something like parsert.protocol = 3

what do you think?

Kind regards

Can't install on Python 2.5 (using FreeBSD)

The results of pip install hiredis:

Downloading/unpacking hiredis
Downloading hiredis-0.1.0.tar.gz
Running setup.py egg_info for package hiredis
Installing collected packages: hiredis
Running setup.py install for hiredis
    building 'hiredis' library
    cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/hiredis.o
    cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Ivendor/hiredis -c vendor/hiredis/net.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/net.o
    cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Ivendor/hiredis -c vendor/hiredis/sds.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/sds.o
    ar -cr build/temp.freebsd-7.2-RELEASE-amd64-2.5/libhiredis.a build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/hiredis.o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/net.o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/sds.o
    building 'hiredis.hiredis' extension
    cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Isrc -Ivendor -I/usr/local/include/python2.5 -c src/hiredis.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/src/hiredis.o
    cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Isrc -Ivendor -I/usr/local/include/python2.5 -c src/reader.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/src/reader.o
    src/reader.c: In function 'freeObject':
    src/reader.c:137: warning: dereferencing 'void *' pointer
    src/reader.c:137: error: request for member 'ob_refcnt' in something not a structure or union
    error: command 'cc' failed with exit status 1
    Complete output from command /usr/local/bin/python2.5 -c "import setuptools;__file__='build/hiredis/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-02VZdu-record/install-record.txt:
    running install

running build

running build_py

creating build

creating build/lib.freebsd-7.2-RELEASE-amd64-2.5

creating build/lib.freebsd-7.2-RELEASE-amd64-2.5/hiredis

copying hiredis/__init__.py -> build/lib.freebsd-7.2-RELEASE-amd64-2.5/hiredis

copying hiredis/version.py -> build/lib.freebsd-7.2-RELEASE-amd64-2.5/hiredis

running build_clib

building 'hiredis' library

creating build/temp.freebsd-7.2-RELEASE-amd64-2.5

creating build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor

creating build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis

cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Ivendor/hiredis -c vendor/hiredis/hiredis.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/hiredis.o

cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Ivendor/hiredis -c vendor/hiredis/net.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/net.o

cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Ivendor/hiredis -c vendor/hiredis/sds.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/sds.o

ar -cr build/temp.freebsd-7.2-RELEASE-amd64-2.5/libhiredis.a build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/hiredis.o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/net.o build/temp.freebsd-7.2-RELEASE-amd64-2.5/vendor/hiredis/sds.o

running build_ext

building 'hiredis.hiredis' extension

creating build/temp.freebsd-7.2-RELEASE-amd64-2.5/src

cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Isrc -Ivendor -I/usr/local/include/python2.5 -c src/hiredis.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/src/hiredis.o

cc -fno-strict-aliasing -DNDEBUG -O2 -fno-strict-aliasing -pipe -O2 -fno-strict-aliasing -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fPIC -Isrc -Ivendor -I/usr/local/include/python2.5 -c src/reader.c -o build/temp.freebsd-7.2-RELEASE-amd64-2.5/src/reader.o

src/reader.c: In function 'freeObject':

src/reader.c:137: warning: dereferencing 'void *' pointer

src/reader.c:137: error: request for member 'ob_refcnt' in something not a structure or union

error: command 'cc' failed with exit status 1

I'm not sure if it's a FreeBSD specific issue since I don't have any other machines with Python 2.5 available.

System info:
FreeBSD 7.2
GCC 4.2.1
Python 2.5.5

Error Compilation OmniOS

Hi,

I had troubles installing hiredis using pip install hiredis on OmniOS however I found a solution that I wanted to share:
CFLAGS=python-config --cflags' -std=c99 -m64' pip install hiredis
(I'm guessing that the SmartOS users will have the same problem.)

I tried to send a pull request to make it available for everyone but I don't know well enough distutils. Hence maybe someone will figure out a way to make it work with this ticket.

Cheers,

Mathieu

hiredis-py ignores string decoding errors

When an encoding is specified (for instance 'utf8'), hiredis-py will attempt to decode string values using that encoding. If the decode raises a ValueError, hiredis-py will ignore the error and return the original bytes.

In my opinion hiredis-py should instead raise a UnicodeDecodeError (or another similar exception) to indicate that the decoding failed. Asking for a decoded string and getting back bytes seems wrong.

Perhaps to mitigate backwards incompatibility issues, a separate strict flag could be introduced with a default value of False. When encoding != None && strict==False, hiredis-py would continue to hide the error and return bytes on error. However when encoding != None && strict==True, hiredis-py would raise an error.

I'm happy to put together a PR for this.

Retrieve partial multi bulk replies.

When a large multibulk reply is transmitted over the network, it can take a while to transmit and process.

Right now, the only API to read parsed tokens is hiredis.Reader.gets().
I'd like to have something, that in case of a multibulk reply, we can already receive a partial multibulk answer, and stream the remaining parts as soon as they're received and feeded to the parser.

That's especially useful for asynchronous code (like asyncio-redis).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.