Skip to content

Commit

Permalink
Make pular python client dependencies optional components (apache#9719)
Browse files Browse the repository at this point in the history
Co-authored-by: Ali Ahmed <[email protected]>
  • Loading branch information
aahmed-se and Ali Ahmed authored Feb 27, 2021
1 parent 3ff7989 commit 569b9e7
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 0 additions & 24 deletions docker/pulsar/scripts/install-pulsar-client-27.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker/pulsar/scripts/install-pulsar-client-37.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]
6 changes: 3 additions & 3 deletions pulsar-client-cpp/docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 26 additions & 10 deletions pulsar-client-cpp/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,36 @@ def build_extension(self, 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,
Expand All @@ -98,4 +113,5 @@ def build_extension(self, ext):
license="Apache License v2.0",
url="https://pulsar.apache.org/",
install_requires=dependencies,
extras_require=extras_require,
)
9 changes: 7 additions & 2 deletions pulsar-client-cpp/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
17 changes: 16 additions & 1 deletion site2/docs/client-libraries-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 569b9e7

Please sign in to comment.