Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build librdkafka when installing confluent-kafka #45

Closed
felixthecat opened this issue Sep 16, 2016 · 24 comments
Closed

build librdkafka when installing confluent-kafka #45

felixthecat opened this issue Sep 16, 2016 · 24 comments

Comments

@felixthecat
Copy link

felixthecat commented Sep 16, 2016

currently when i do a pip install confluent-kafka, it fails because i haven't built librdkafka yet. it'd be nice if your setup.py could also build librdkafka to make the installation process easier. there are multiple internal services using our client that's a wrapper around confluent-kafka, and we'd like it if they could just do a simple pip install our-client. this is a little more difficult for us since we then have to automate the build process on our end.

basically i'm hoping you can do something similar to what librabbitmq (https://pypi.python.org/pypi/librabbitmq) is doing.

@ZmeiGorynych
Copy link

I run into apparently the same error - can it be fixed manually?

   x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c confluent_kafka/src/confluent_kafka.c -o build/temp.linux-x86_64-2.7/confluent_kafka/src/confluent_kafka.o
    In file included from confluent_kafka/src/confluent_kafka.c:17:0:
    confluent_kafka/src/confluent_kafka.h:20:32: fatal error: librdkafka/rdkafka.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

@edenhill
Copy link
Contributor

@ZmeiGorynych Download, build and install librdkafka manually:

curl -L https://github.com/edenhill/librdkafka/archive/v0.9.2-RC1.tar.gz | tar xzf -
cd librdkafka-0.9.2-RC1/
./configure --prefix=/usr
make -j
sudo make install

Then try to build/install confluent-kafka-python again.

@edenhill
Copy link
Contributor

Re issue in general: we'll investigate what bootstrapping librdkafka through setup.py might look like.

@ZmeiGorynych
Copy link

That seems to have worked, thanks!
The only strangeness is that I had to do sudo pip install confluent-kafka as installing as me gave
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/confluent_kafka-0.9.1.2.dist-info'

@ZmeiGorynych
Copy link

Please, what's the equivalent for Windows?

When trying to install on Windows 10 Home, I'm getting the following error
install_error.txt

@edenhill
Copy link
Contributor

While the client probably works on Windows, it is currently an unsupported platform, so I really can't help you, but looking at the errors it seems that it can't find the librdkafka headers.

@edenhill
Copy link
Contributor

edenhill commented Feb 6, 2017

We're looking into bundling prebuilt librdkafka libraries with the Python client (bdist/wheel) on platforms where dependency management is messy (such as OSX and Windows).

@rmax
Copy link
Contributor

rmax commented Mar 23, 2017

FYI, conda has linux and osx packages for librdkafka: conda install -c conda-forge librdkafka

@linsimiao
Copy link

linsimiao commented Mar 27, 2017

and if you are using mac,and you install a python of other version,you should use "./configure --prefix=/usr/local" instead of "./configure --prefix=/usr"

@mtrienis
Copy link

mtrienis commented Mar 29, 2017

In case folks are interested:

You can use manylinux with auditwheel to build standalone Python wheel that bundles librdkafka (and other c dependencies) inside.

Steps:

  1. Build confluent-kafka-python wheel python setup.py bdist_wheel
  2. Build and install librdkafka: ./configure && make && make install
  3. Repair python wheel auditwheel repair confluent_kafka-x.whl -w dist

For step 2. and step 3. make sure you use the appropriate docker container: e.g. quay.io/pypa/manylinux1_x86_64

@edenhill
Copy link
Contributor

@mtrienis Very cool, I'll look into that!

@edenhill
Copy link
Contributor

edenhill commented Sep 1, 2017

This is in the works.

@ghost
Copy link

ghost commented Mar 25, 2018

tried to install from wheel with deb9

    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-MLq5fN/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/user/Downloads/hivemall/workbench/kafka/python/venv/include/python3.5m -c confluent_kafka/src/confluent_kafka.c -o build/temp.linux-x86_64-3.5/confluent_kafka/src/confluent_kafka.o
    In file included from confluent_kafka/src/confluent_kafka.c:17:0:
    confluent_kafka/src/confluent_kafka.h:21:32: fatal error: librdkafka/rdkafka.h: No such file or directory
     #include <librdkafka/rdkafka.h>
                                    ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/user/Downloads/hivemall/workbench/kafka/python/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kd4t9loi/confluent-kafka/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-_pmetczv-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/Downloads/hivemall/workbench/kafka/python/venv/include/site/python3.5/confluent-kafka" failed with error code 1 in /tmp/pip-build-kd4t9loi/confluent-kafka/

apt-get is outdated with 0.9.3

How to use the bundled pip/wheel install?

@edenhill
Copy link
Contributor

@ItsmeJulian Try this: #184 (comment)

@edenhill
Copy link
Contributor

Binary wheels now (v0.11.4) contain librdkafka

@ZeeD
Copy link

ZeeD commented Sep 19, 2018

Are binary wheels only for mac and linux? is windows a supported platform?

@edenhill
Copy link
Contributor

We just merged experimental windows support. Please try the EXPERIMENTAL packages here and let us know the result:
https://ci.appveyor.com/project/ConfluentClientEngineering/confluent-kafka-python/build/0.11.0.176/artifacts

@ZeeD
Copy link

ZeeD commented Sep 24, 2018

Hi
I have fetched the artifact (confluent_kafka-0.11.5-cp36-cp36m-win_amd64.whl) friday and used to make some tests with a local kafka. So far all is working

@pauelm
Copy link

pauelm commented Jul 10, 2020

I am currently running into the same issue on Windows. I notice that the latest pip package at this time is 05-22-2020. Are there currently any plans to fix, and if so, is there any active development getting tracking on this? While there have been newer versions released along the way, I see that this same problem was reported unresolved 4 YEARS ago, so it would be nice to get this fixed and packaged so that it can be loaded on Windows properly.

If not, then I will just move forward with other Kafka solutions.

pip-install-4gju67pi\confluent-kafka\confluent_kafka\src\confluent_kafka.h(22): fatal error C1083: Cannot open include file: 'librdkafka/rdkafka.h': No such file or directory

Additional references to this issue:
https://stackoverflow.com/questions/51963121/how-to-install-confluent-kafka-python-on-windows-10

Another solution attempt I tried that was also unsuccessful:
pip install --pre --index-url https://test.pypi.org/simple/ confluent_kafka

@edenhill
Copy link
Contributor

@pauelm What Python version are you on?

@pauelm
Copy link

pauelm commented Jul 10, 2020

I am currently on version 3.8.2

@edenhill
Copy link
Contributor

We're still having problems with the cibuildwheel packaging of confluent-kafka for Py 3.8 on Windows, I believe Py 3.7 should work.

@pauelm
Copy link

pauelm commented Jul 10, 2020

I dropped down to version 3.6.6 and successfully pipped confluent-kafka 1.4.2. I will give this a shot and report back if I run into any issues. Thanks for your help Magnus!

-Paul

Note: I initially dropped down to 3.7.6, but the following errors were thrown:
ERROR: Could not find a version that satisfies the requirement confluent-kafka (from versions: none)
ERROR: No matching distribution found for confluent-kafka

@cicipp
Copy link

cicipp commented Oct 24, 2020

It worked on my computer with Python version 3.7.0 and confluent-kafka version 1.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants