Skip to content

Commit

Permalink
Added venv info to example README.md (confluentinc#1099)
Browse files Browse the repository at this point in the history
* Added venv info to example README.md

* review feedback

* remove python setup.py build
  • Loading branch information
Matt Howlett authored Apr 21, 2021
1 parent f7e09e1 commit 5aa2406
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ tests/docker/conf/tls/*
.idea
tmp-KafkaCluster
.venv
venv_test
venv_examples
43 changes: 38 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
The scripts in this directory provide code examples using Confluent's Python client:

* [adminapi.py](adminapi.py): collection of Kafka Admin API operations
* [adminapi.py](adminapi.py): Collection of Kafka Admin API operations
* [asyncio_example.py](asyncio_example.py): AsyncIO webserver with Kafka producer
* [avro-cli.py](avro-cli.py): produces Avro messages with Confluent Schema Registry and then reads them back again
* [consumer.py](consumer.py): reads messages from a Kafka topic
* [producer.py](producer.py): reads lines from stdin and sends them to Kafka
* [eos-transactions.py](eos-transactions.py): transactional producer with exactly once semantics (EOS)
* [avro-cli.py](avro-cli.py): Produces Avro messages with Confluent Schema Registry and then reads them back again
* [consumer.py](consumer.py): Reads messages from a Kafka topic
* [producer.py](producer.py): Reads lines from stdin and sends them to Kafka
* [eos-transactions.py](eos-transactions.py): Transactional producer with exactly once semantics (EOS)
* [avro_producer.py](avro_producer.py): SerializingProducer with AvroSerializer
* [avro_consumer.py](avro_consumer.py): DeserializingConsumer with AvroDeserializer
* [json_producer.py](json_producer.py): SerializingProducer with JsonSerializer
Expand All @@ -20,3 +20,36 @@ Additional examples for [Confluent Cloud](https://www.confluent.io/confluent-clo

* [confluent_cloud.py](confluent_cloud.py): produces messages to Confluent Cloud and then reads them back again
* [confluentinc/examples](https://github.com/confluentinc/examples/tree/master/clients/cloud/python): integrates Confluent Cloud and Confluent Cloud Schema Registry

## venv setup

It's usually a good idea to install Python dependencies in a virtual environment to avoid
conflicts between projects.

To setup a venv with the latest release version of confluent-kafka and dependencies of all examples installed:

```
$ python3 -m venv venv_examples
$ source venv_examples/bin/activate
$ cd examples
$ pip install -r requirements.txt
```

To setup a venv that uses the current source tree version of confluent_kafka, you
need to have a C compiler and librdkafka installed
([from a package](https://github.com/edenhill/librdkafka#installing-prebuilt-packages), or
[from source](https://github.com/edenhill/librdkafka#build-from-source)). Then:

```
$ python3 -m venv venv_examples
$ source venv_examples/bin/activate
$ python setup.py develop
$ cd examples
$ pip install -r requirements.txt
```

When you're finished with the venv:

```
$ deactivate
```
2 changes: 1 addition & 1 deletion examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
confluent-kafka[examples]
confluent-kafka
fastapi
pydantic
uvicorn
Expand Down

0 comments on commit 5aa2406

Please sign in to comment.