This repository was archived by the owner on Mar 24, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -159,8 +159,16 @@ Using the librdkafka extension
159159------------------------------
160160
161161PyKafka includes a C extension that makes use of librdkafka to speed up producer
162- and consumer operation. PyKafka requires librdkafka v0.9.1+. Some system package managers may
163- not have up-to-date versions. To use the librdkafka extension, you need to make sure the header
162+ and consumer operation.
163+
164+ To ensure the C extension is compiled, set environment variable ``RDKAFKA_INSTALL=system `` during
165+ ``pip install `` or ``setup.py ``, i.e. ``RDKAFKA_INSTALL=system pip install pykafka ``.
166+ The setup will fail if C extension is not compiled. Oppositely, if ``RDKAFKA_INSTALL='' ``, this
167+ explicitly specifies that the C extension should not be compiled. The current default behavior is
168+ to compile the extension but will not fail the setup if compilation fails.
169+
170+ PyKafka requires librdkafka v0.9.1+. Some system package managers may not have
171+ up-to-date versions. To use the librdkafka extension, you need to make sure the header
164172files and shared library are somewhere where python can find them, both when you build
165173the extension (which is taken care of by ``setup.py develop ``) and at run time.
166174Typically, this means that you need to either install librdkafka in a place
Original file line number Diff line number Diff line change @@ -184,8 +184,19 @@ def run_setup(with_rdkafka=True):
184184 ]
185185 )
186186
187+
188+ # Use environment variable RDKAFKA_INSTALL to explicitly specify whether rdkafka c extension should be compiled
189+ # 'system': Compile with librdkafka installed in system
190+ # '' (empty string): No compile
191+ rdkafka_install_type = os .environ .get ('RDKAFKA_INSTALL' )
192+
187193try :
188- if not is_cpython :
194+ if rdkafka_install_type == '' :
195+ run_setup (with_rdkafka = False )
196+ elif not is_cpython :
197+ if rdkafka_install_type == 'system' :
198+ raise Exception ("librdkafka is not supported under %s, but RDKAFKA_INSTALL specified"
199+ % python_implementation )
189200 print ("librdkafka is not supported under %s" % python_implementation )
190201 print (15 * "-" )
191202 print ("INFO: Failed to build rdkafka extension:" )
@@ -195,6 +206,8 @@ def run_setup(with_rdkafka=True):
195206 else :
196207 run_setup ()
197208except ve_build_ext .BuildFailed as exc :
209+ if rdkafka_install_type == 'system' :
210+ raise
198211 print (15 * "-" )
199212 print ("INFO: Failed to build rdkafka extension:" )
200213 print (exc .cause )
You can’t perform that action at this time.
0 commit comments