Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C183D200D63 for ; Thu, 21 Dec 2017 11:52:20 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C080B160C2B; Thu, 21 Dec 2017 10:52:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 11F06160C1A for ; Thu, 21 Dec 2017 11:52:19 +0100 (CET) Received: (qmail 45667 invoked by uid 500); 21 Dec 2017 10:52:19 -0000 Mailing-List: contact commits-help@pulsar.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.incubator.apache.org Delivered-To: mailing list commits@pulsar.incubator.apache.org Received: (qmail 45658 invoked by uid 99); 21 Dec 2017 10:52:19 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Dec 2017 10:52:19 +0000 From: GitBox To: commits@pulsar.apache.org Subject: [GitHub] merlimat closed pull request #996: Add table listing supported Python versions Message-ID: <151385353865.25516.2897368118105761816.gitbox@gitbox.apache.org> archived-at: Thu, 21 Dec 2017 10:52:20 -0000 merlimat closed pull request #996: Add table listing supported Python versions URL: https://github.com/apache/incubator-pulsar/pull/996 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/site/docs/latest/clients/Python.md b/site/docs/latest/clients/Python.md index fb3bdbb72..9b36358e4 100644 --- a/site/docs/latest/clients/Python.md +++ b/site/docs/latest/clients/Python.md @@ -28,18 +28,28 @@ tags: The Pulsar Python client library is a wrapper over the existing [C++ client library](../Cpp) and exposes all of the [same features](../../../../api/cpp). You can find the code in the [`python` subdirectory]({{ site.pulsar_repo }}/pulsar-client-cpp/python) of the C++ client code. - ## Installation -You can install the `pulsar-client` library either using [pip](https://pip.pypa.io/en/stable/) or by building the library from source. +You can install the [`pulsar-client`](https://pypi.python.org/pypi/pulsar-client) library either via [PyPi](https://pypi.python.org/pypi), using [pip](#installation-using-pip), or by building the library from source. + +### Installation using pip -To install using pip: +To install the `pulsar-client` library as a pre-built package using the [pip](https://pip.pypa.io/en/stable/) package manager: ```shell $ pip install pulsar-client ``` -To install by building from source, follow the [instructions](../Cpp#compilation) and compile the Pulsar C++ client library. That will also build the Python binding for the library. +Installation via PyPi is available for the following Python versions: + +Platform | Supported Python versions +:--------|:------------------------- +MacOS 10.12 (Sierra) and 10.13 (High Sierra) | 2.7, 3.6 +Linux | 2.7, 3.3, 3.4, 3.5, 3.6 + +### Installing from source + +To install the `pulsar-client` library by building from source, follow [these instructions](../Cpp#compilation) and compile the Pulsar C++ client library. That will also build the Python binding for the library. To install the built Python bindings: @@ -49,11 +59,9 @@ $ cd pulsar/pulsar-client-cpp/python $ sudo python setup.py install ``` -{% include admonition.html type="info" content="Currently, the only supported Python version is 2.7." %} - ## API Reference -The complete Python API reference is available at [api/python]({{site.baseUrl}}/api/python) +The complete Python API reference is available at [api/python]({{site.baseUrl}}/api/python). ## Examples @@ -61,15 +69,17 @@ Below you'll find a variety of Python code examples for the `pulsar-client` libr ### Producer example -This would create a Python {% popover producer %} for the `persistent://sample/standalone/ns/my-topic` topic and send 10 messages on that topic: +This creates a Python {% popover producer %} for the `persistent://sample/standalone/ns/my-topic` topic and send 10 messages on that topic: ```python import pulsar -client = pulsar.Client('pulsar://localhost:6650') +TOPIC = 'persistent://sample/standalone/ns/my-topic' +PULSAR_SERVICE_URL = 'pulsar://localhost:6650' -producer = client.create_producer( - 'persistent://sample/standalone/ns/my-topic') +client = pulsar.Client(PULSAR_SERVICE_URL) + +producer = client.create_producer(TOPIC) for i in range(10): producer.send('Hello-%d' % i) @@ -79,15 +89,12 @@ client.close() ### Consumer example -This would create a {% popover consumer %} with the `my-sub` {% popover subscription %} on the `persistent://sample/standalone/ns/my-topic` topic, listen for incoming messages, print the content and ID of messages that arrive, and {% popover acknowledge %} each message to the Pulsar {% popover broker %}: +This creates a {% popover consumer %} with the `my-sub` {% popover subscription %} on the `persistent://sample/standalone/ns/my-topic` topic, listen for incoming messages, print the content and ID of messages that arrive, and {% popover acknowledge %} each message to the Pulsar {% popover broker %}: ```python -import pulsar +SUBSCRIPTION = 'my-sub' -client = pulsar.Client('pulsar://localhost:6650') -consumer = client.subscribe( - 'persistent://sample/standalone/ns/my-topic', - 'my-sub') +consumer = client.subscribe(TOPIC, SUBSCRIPTION) while True: msg = consumer.receive() @@ -96,28 +103,3 @@ while True: client.close() ``` - -### Async producer example - -This would create a Pulsar {% popover producer %} that sends messages asynchronously and triggers the `send_callback` callback function whenever messages are {% popover acknowledged %} by the {% popover broker %}: - -```python -import pulsar - -client = pulsar.Client('pulsar://localhost:6650') - -producer = client.create_producer( - 'persistent://sample/standalone/ns/my-topic', - block_if_queue_full=True, - batching_enabled=True, - batching_max_publish_delay_ms=10 - ) - -def send_callback(res, msg): - print('Message published res=%s', res) - -while True: - producer.send_async('Hello-%d' % i, send_callback) - -client.close() -``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services