Skip to content

Commit b0c5930

Browse files
authored
Cleanup install instructions for optional libs (#2139)
This cleans up the install instructions to specify that optional libs should be installed using the `kafka-python[opt]` format. This leverages `setuptools`' `extra_requires` feature to let our users choose to inherit any versions pins we might apply to our optional dependencies. This also re-orders the docs slightly to give more visibility to the `crc32c` install because users are unlikely to realize it exists. It also cleans up the formatting of the compression libraries slightly, as they were getting a little unwieldy.
1 parent 8b8a48b commit b0c5930

File tree

3 files changed

+57
-31
lines changed

3 files changed

+57
-31
lines changed

README.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ documentation, please see readthedocs and/or python's inline help.
3434

3535
>>> pip install kafka-python
3636

37+
3738
KafkaConsumer
3839
*************
3940

@@ -78,6 +79,7 @@ that expose basic message attributes: topic, partition, offset, key, and value:
7879
>>> # Get consumer metrics
7980
>>> metrics = consumer.metrics()
8081

82+
8183
KafkaProducer
8284
*************
8385

@@ -124,6 +126,7 @@ for more details.
124126
>>> # Get producer performance metrics
125127
>>> metrics = producer.metrics()
126128

129+
127130
Thread safety
128131
*************
129132

@@ -133,22 +136,30 @@ KafkaConsumer which cannot.
133136
While it is possible to use the KafkaConsumer in a thread-local manner,
134137
multiprocessing is recommended.
135138

139+
136140
Compression
137141
***********
138142

139-
kafka-python supports gzip compression/decompression natively. To produce or consume lz4
140-
compressed messages, you should install python-lz4 (pip install lz4).
141-
To enable snappy compression/decompression install python-snappy (also requires snappy library).
142-
See <https://kafka-python.readthedocs.io/en/master/install.html#optional-snappy-install>
143-
for more information.
143+
kafka-python supports the following compression formats:
144+
145+
- gzip
146+
- LZ4
147+
- Snappy
148+
- Zstandard (zstd)
149+
150+
gzip is supported natively, the others require installing additional libraries.
151+
See <https://kafka-python.readthedocs.io/en/master/install.html> for more information.
152+
144153

145154
Optimized CRC32 Validation
146155
**************************
147156

148157
Kafka uses CRC32 checksums to validate messages. kafka-python includes a pure
149158
python implementation for compatibility. To improve performance for high-throughput
150159
applications, kafka-python will use `crc32c` for optimized native code if installed.
151-
See https://pypi.org/project/crc32c/
160+
See <https://kafka-python.readthedocs.io/en/master/install.html> for installation instructions.
161+
See https://pypi.org/project/crc32c/ for details on the underlying crc32c lib.
162+
152163

153164
Protocol
154165
********

docs/index.rst

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ documentation, please see readthedocs and/or python's inline help.
3333

3434
>>> pip install kafka-python
3535

36+
3637
KafkaConsumer
3738
*************
3839

@@ -122,12 +123,26 @@ multiprocessing is recommended.
122123
Compression
123124
***********
124125

125-
kafka-python supports multiple compression types:
126+
kafka-python supports the following compression formats:
127+
128+
- gzip
129+
- LZ4
130+
- Snappy
131+
- Zstandard (zstd)
132+
133+
gzip is supported natively, the others require installing additional libraries.
134+
See `Install <install.html>`_ for more information.
135+
136+
137+
Optimized CRC32 Validation
138+
**************************
139+
140+
Kafka uses CRC32 checksums to validate messages. kafka-python includes a pure
141+
python implementation for compatibility. To improve performance for high-throughput
142+
applications, kafka-python will use `crc32c` for optimized native code if installed.
143+
See `Install <install.html>`_ for installation instructions and
144+
https://pypi.org/project/crc32c/ for details on the underlying crc32c lib.
126145

127-
- gzip : supported natively
128-
- lz4 : requires `python-lz4 <https://pypi.org/project/lz4/>`_ installed
129-
- snappy : requires the `python-snappy <https://pypi.org/project/python-snappy/>`_ package (which requires the snappy C library)
130-
- zstd : requires the `python-zstandard <https://github.com/indygreg/python-zstandard>`_ package installed
131146

132147
Protocol
133148
********

docs/install.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,33 @@ Bleeding-Edge
2323
pip install ./kafka-python
2424
2525
26-
Optional LZ4 install
26+
Optional crc32c install
27+
***********************
28+
Highly recommended if you are using Kafka 11+ brokers. For those `kafka-python`
29+
uses a new message protocol version, that requires calculation of `crc32c`,
30+
which differs from the `zlib.crc32` hash implementation. By default `kafka-python`
31+
calculates it in pure python, which is quite slow. To speed it up we optionally
32+
support https://pypi.python.org/pypi/crc32c package if it's installed.
33+
34+
.. code:: bash
35+
36+
pip install 'kafka-python[crc32c]'
37+
38+
39+
Optional ZSTD install
2740
********************
2841

29-
To enable LZ4 compression/decompression, install python-lz4:
42+
To enable ZSTD compression/decompression, install python-zstandard:
3043

31-
>>> pip install lz4
44+
>>> pip install 'kafka-python[zstd]'
3245

3346

34-
Optional crc32c install
47+
Optional LZ4 install
3548
********************
3649

37-
To enable optimized CRC32 checksum validation, install crc32c:
50+
To enable LZ4 compression/decompression, install python-lz4:
3851

39-
>>> pip install crc32c
52+
>>> pip install 'kafka-python[lz4]'
4053

4154

4255
Optional Snappy install
@@ -77,17 +90,4 @@ Install the `python-snappy` module
7790

7891
.. code:: bash
7992
80-
pip install python-snappy
81-
82-
83-
Optional crc32c install
84-
***********************
85-
Highly recommended if you are using Kafka 11+ brokers. For those `kafka-python`
86-
uses a new message protocol version, that requires calculation of `crc32c`,
87-
which differs from `zlib.crc32` hash implementation. By default `kafka-python`
88-
calculates it in pure python, which is quite slow. To speed it up we optionally
89-
support https://pypi.python.org/pypi/crc32c package if it's installed.
90-
91-
.. code:: bash
92-
93-
pip install crc32c
93+
pip install 'kafka-python[snappy]'

0 commit comments

Comments
 (0)