This is an automated email from the ASF dual-hosted git repository.
aahmed pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 569b9e7 Make pular python client dependencies optional components
(#9719)
569b9e7 is described below
commit 569b9e7888be04d51624f5d2cc2e73f7aae38653
Author: Ali Ahmed <[email protected]>
AuthorDate: Sat Feb 27 02:41:35 2021 -0800
Make pular python client dependencies optional components (#9719)
Co-authored-by: Ali Ahmed <[email protected]>
---
.github/workflows/ci-cpp.yaml | 2 +-
docker/pulsar/scripts/install-pulsar-client-27.sh | 24 ---------------
docker/pulsar/scripts/install-pulsar-client-37.sh | 2 +-
pulsar-client-cpp/docker-tests.sh | 6 ++--
pulsar-client-cpp/python/setup.py | 36 ++++++++++++++++-------
pulsar-client-cpp/run-unit-tests.sh | 9 ++++--
site2/docs/client-libraries-python.md | 17 ++++++++++-
7 files changed, 54 insertions(+), 42 deletions(-)
diff --git a/.github/workflows/ci-cpp.yaml b/.github/workflows/ci-cpp.yaml
index 1887b43..0e267f5 100644
--- a/.github/workflows/ci-cpp.yaml
+++ b/.github/workflows/ci-cpp.yaml
@@ -86,4 +86,4 @@ jobs:
- name: run c++ tests
if: steps.docs.outputs.changed_only == 'no'
- run: ./build/retry.sh pulsar-client-cpp/docker-tests.sh
+ run: pulsar-client-cpp/docker-tests.sh
diff --git a/docker/pulsar/scripts/install-pulsar-client-27.sh
b/docker/pulsar/scripts/install-pulsar-client-27.sh
deleted file mode 100755
index 973c69c..0000000
--- a/docker/pulsar/scripts/install-pulsar-client-27.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-set -x
-
-WHEEL_FILE=$(ls /pulsar/pulsar-client | grep cp27)
-pip2 install /pulsar/pulsar-client/${WHEEL_FILE}
diff --git a/docker/pulsar/scripts/install-pulsar-client-37.sh
b/docker/pulsar/scripts/install-pulsar-client-37.sh
index 9d3714c..44932b6 100755
--- a/docker/pulsar/scripts/install-pulsar-client-37.sh
+++ b/docker/pulsar/scripts/install-pulsar-client-37.sh
@@ -21,4 +21,4 @@
set -x
WHEEL_FILE=$(ls /pulsar/pulsar-client | grep cp37)
-pip3.7 install /pulsar/pulsar-client/${WHEEL_FILE}
+pip3.7 install /pulsar/pulsar-client/${WHEEL_FILE}[all]
diff --git a/pulsar-client-cpp/docker-tests.sh
b/pulsar-client-cpp/docker-tests.sh
index 0969c1c..651e528 100755
--- a/pulsar-client-cpp/docker-tests.sh
+++ b/pulsar-client-cpp/docker-tests.sh
@@ -48,12 +48,12 @@ DOCKER_CMD="docker run -i -v $ROOT_DIR:/pulsar $IMAGE"
for args in "$@"
do
arg=$(echo $args | cut -f1 -d=)
- val=$(echo $args | cut -f2 -d=)
+ val=$(echo $args | cut -f2 -d=)
case "$arg" in
--tests) tests=${val} ;;
- *)
- esac
+ *)
+ esac
done
# Start 2 Pulsar standalone instances (one with TLS and one without)
diff --git a/pulsar-client-cpp/python/setup.py
b/pulsar-client-cpp/python/setup.py
index 4e59150..d012dfc 100644
--- a/pulsar-client-cpp/python/setup.py
+++ b/pulsar-client-cpp/python/setup.py
@@ -70,21 +70,36 @@ class my_build_ext(build_ext.build_ext):
raise
shutil.copyfile('_pulsar.so', self.get_ext_fullpath(ext.name))
-
+# Core Client dependencies
dependencies = [
- 'fastavro==0.24.0',
- 'grpcio<1.28,>=1.8.2',
- 'protobuf>=3.6.1',
'six',
'certifi',
- 'enum34>=1.1.9; python_version < "3.4"',
-
- # functions dependencies
- "apache-bookkeeper-client>=4.9.2",
- "prometheus_client",
- "ratelimit"
+ 'enum34>=1.1.9; python_version < "3.4"'
]
+extras_require = {}
+
+# functions dependencies
+extras_require["functions"] = sorted(
+ {
+ "protobuf>=3.6.1",
+ "grpcio<1.28,>=1.8.2",
+ "apache-bookkeeper-client>=4.9.2",
+ "prometheus_client",
+ "ratelimit"
+ }
+)
+
+# avro dependencies
+extras_require["avro"] = sorted(
+ {
+ "fastavro==0.24.0"
+ }
+)
+
+# all dependencies
+extras_require["all"] = sorted(set(sum(extras_require.values(), [])))
+
setup(
name=NAME,
version=VERSION,
@@ -98,4 +113,5 @@ setup(
license="Apache License v2.0",
url="https://pulsar.apache.org/",
install_requires=dependencies,
+ extras_require=extras_require,
)
diff --git a/pulsar-client-cpp/run-unit-tests.sh
b/pulsar-client-cpp/run-unit-tests.sh
index f9429d8..5dcab89 100755
--- a/pulsar-client-cpp/run-unit-tests.sh
+++ b/pulsar-client-cpp/run-unit-tests.sh
@@ -24,6 +24,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
cd $ROOT_DIR/pulsar-client-cpp
./pulsar-test-service-start.sh
+
pushd tests
if [ -f /gtest-parallel/gtest-parallel ]; then
@@ -47,8 +48,12 @@ if [ $RES -eq 0 ]; then
echo "---- Build Python Wheel file"
python setup.py bdist_wheel
- echo "---- Installing Python Wheel file"
- pip install dist/pulsar_client-*-linux_x86_64.whl
+ echo "---- Installing Python Wheel file"
+ ls -lha dist
+ WHEEL_FILE=$(ls dist/ | grep whl)
+ echo "${WHEEL_FILE}"
+ echo "dist/${WHEEL_FILE}[all]"
+ pip install dist/${WHEEL_FILE}[all]
echo "---- Running Python unit tests"
diff --git a/site2/docs/client-libraries-python.md
b/site2/docs/client-libraries-python.md
index 99ad016..d15cec6 100644
--- a/site2/docs/client-libraries-python.md
+++ b/site2/docs/client-libraries-python.md
@@ -22,12 +22,27 @@ To install the `pulsar-client` library as a pre-built
package using the [pip](ht
$ pip install pulsar-client=={{pulsar:version_number}}
```
+### Optional dependencies
+
+To support aspects like pulsar functions or Avro serialization, additional
optional components can be installed alongside the `pulsar-client` library
+
+```shell
+# avro serialization
+$ pip install pulsar-client=='{{pulsar:version_number}}[avro]'
+
+# functions runtime
+$ pip install pulsar-client=='{{pulsar:version_number}}[functions]'
+
+# all optional components
+$ pip install pulsar-client=='{{pulsar:version_number}}[all]'
+```
+
Installation via PyPi is available for the following Python versions:
Platform | Supported Python versions
:--------|:-------------------------
MacOS <br /> 10.13 (High Sierra), 10.14 (Mojave) <br /> | 2.7, 3.7
-Linux | 2.7, 3.4, 3.5, 3.6, 3.7
+Linux | 2.7, 3.4, 3.5, 3.6, 3.7, 3.8
### Install from source