Skip to content

Commit 86a6160

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 70453e8 + 79e4579 commit 86a6160

File tree

11 files changed

+575
-123
lines changed

11 files changed

+575
-123
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
environment:
22
global:
3-
LIBRDKAFKA_NUGET_VERSION: 0.11.6-RC3
3+
LIBRDKAFKA_NUGET_VERSION: 0.11.6
44
CIBW_SKIP: cp33-* cp34-*
55
CIBW_TEST_REQUIRES: pytest requests avro
66
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ wheelhouse
2020
dl-*
2121
*.whl
2222
.pytest_cache
23+
staging

.travis.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
matrix:
22
include:
3-
# Source package verification with Python 2.7 and librdkafka v0.11.6-RC3
3+
# Source package verification with Python 2.7 and librdkafka v0.11.6
44
- os: linux
55
language: python
66
dist: trusty
77
python: "2.7"
8-
env: LD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6-RC3
9-
# Source package verification with Python 3.6 and librdkafka v0.11.6-RC3
8+
env: LD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6
9+
# Source package verification with Python 3.6 and librdkafka v0.11.6
1010
- os: linux
1111
language: python
1212
dist: trusty
1313
python: "3.6"
14-
env: LD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6-RC3
15-
# Source package verification with Python 2.7 and librdkafka v0.11.6-RC3
14+
env: LD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6
15+
# Source package verification with Python 2.7 and librdkafka v0.11.6
1616
- os: osx
1717
python: "2.7"
18-
env: LD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6-RC3
18+
env: DYLD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6
1919
before_install:
2020
- pip install -U pip && pip install virtualenv
2121
- brew update && brew upgrade pyenv
2222
- pyenv install -f 2.7.15
2323
- pip install virtualenv
2424
- virtualenv -p ~/.pyenv/versions/2.7.15/bin/python ./env
2525
- source env/bin/activate
26-
# Source package verification with Python 3.6 and librdkafka v0.11.6-RC3
26+
# Source package verification with Python 3.6 and librdkafka v0.11.6
2727
- os: osx
2828
python: "3.6"
29-
env: LD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6-RC3
29+
env: DYLD_LIBRARY_PATH="$PWD/tmp-build/lib" LIBRDKAFKA_VERSION=v0.11.6
3030
before_install:
3131
- pip install -U pip && pip install virtualenv
3232
- brew update && brew upgrade pyenv
@@ -36,35 +36,38 @@ matrix:
3636
- source env/bin/activate
3737
# cibuildwheel for osx
3838
- os: osx
39-
env: CIBW_BEFORE_BUILD="tools/bootstrap-librdkafka.sh --require-ssl v0.11.6-RC3 tmp" CFLAGS="-Itmp/include" LDFLAGS="-Ltmp/lib"
39+
env: CIBW_BEFORE_BUILD="tools/bootstrap-librdkafka.sh --require-ssl v0.11.6 tmp" CFLAGS="-Itmp/include" LDFLAGS="-Ltmp/lib"
4040
before_install:
4141
- brew update && brew upgrade pyenv
4242
- pip install virtualenv
4343
# cibuildwheel for manylinux
4444
- os: linux
4545
dist: trusty
4646
sudo: required
47-
env: CIBW_BEFORE_BUILD="tools/prepare-cibuildwheel-linux.sh v0.11.6-RC3"
47+
env: CIBW_BEFORE_BUILD="tools/prepare-cibuildwheel-linux.sh v0.11.6"
4848
language: python
4949
python: "2.7"
5050
services: docker
5151

5252
install:
53+
- tools/install-interceptors.sh
5354
- pip install -U pip && pip install virtualenv
5455
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then python -m ensurepip && virtualenv /tmp/venv && source /tmp/venv/bin/activate ; fi
55-
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then rvm get stable; fi
56+
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then rvm get stable; fi
5657
- if [[ -z $CIBW_BEFORE_BUILD ]]; then pip install pytest-timeout flake8 ; fi
5758
- if [[ -z $CIBW_BEFORE_BUILD ]]; then rm -rf tmp-build ; tools/bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} tmp-build ; fi
5859
- if [[ -n $TRAVIS_TAG && -n $CIBW_BEFORE_BUILD ]]; then pip install cibuildwheel; fi
5960

60-
6161
script:
6262
- if [[ -z $CIBW_BEFORE_BUILD ]]; then pip install -v --global-option=build_ext --global-option="-Itmp-build/include/" --global-option="-Ltmp-build/lib" . .[avro] ; fi
6363
- if [[ -z $CIBW_BEFORE_BUILD ]]; then flake8 ; fi
64-
- if [[ -z $CIBW_BEFORE_BUILD ]]; then py.test -v --timeout 20 --ignore=tmp-build --import-mode append ; fi
65-
- if [[ -n $TRAVIS_TAG && -n $CIBW_BEFORE_BUILD ]]; then cibuildwheel --output-dir wheelhouse ; ls -la wheelhouse/ ; fi
64+
# Make plugins available for tests
65+
- ldd staging/libs/* || otool -L staging/libs/* || true
66+
- if [[ -z $CIBW_BEFORE_BUILD && $TRAVIS_OS_NAME == "osx" ]]; then DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:staging/libs py.test -v --timeout 20 --ignore=tmp-build --import-mode append ; fi
67+
- if [[ -z $CIBW_BEFORE_BUILD && $TRAVIS_OS_NAME == "linux" ]]; then LD_LIBRARY_PATH=$LD_LIBRARY_PATH:staging/libs py.test -v --timeout 20 --ignore=tmp-build --import-mode append ; fi
68+
- if [[ -n $TRAVIS_TAG && -n $CIBW_BEFORE_BUILD ]]; then cibuildwheel --output-dir wheelhouse1 && tools/fixup-wheels.sh wheelhouse1 wheelhouse ; fi
6669
- if [[ -n $TRAVIS_TAG && $TRAVIS_OS_NAME == linux && -n $CIBW_BEFORE_BUILD ]]; then tools/test-manylinux.sh ; fi
67-
70+
- if [[ -n $TRAVIS_TAG && $TRAVIS_OS_NAME == osx && -n $CIBW_BEFORE_BUILD ]]; then tools/test-osx.sh; fi
6871

6972
deploy:
7073
provider: s3

confluent_kafka/__init__.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,61 @@ def __init__(self, broker_name,
4242

4343
def __str__(self):
4444
return "{}/{} throttled for {} ms".format(self.broker_name, self.broker_id, int(self.throttle_time * 1000))
45+
46+
47+
def _resolve_plugins(plugins):
48+
""" Resolve embedded plugins from the wheel's library directory.
49+
50+
For internal module use only.
51+
52+
:param str plugins: The plugin.library.paths value
53+
"""
54+
import os
55+
from sys import platform
56+
57+
# Location of __init__.py and the embedded library directory
58+
basedir = os.path.dirname(__file__)
59+
60+
if platform in ('win32', 'cygwin'):
61+
paths_sep = ';'
62+
ext = '.dll'
63+
libdir = basedir
64+
elif platform in ('linux', 'linux2'):
65+
paths_sep = ':'
66+
ext = '.so'
67+
libdir = os.path.join(basedir, '.libs')
68+
elif platform == 'darwin':
69+
paths_sep = ':'
70+
ext = '.dylib'
71+
libdir = os.path.join(basedir, '.dylibs')
72+
else:
73+
# Unknown platform, there are probably no embedded plugins.
74+
return plugins
75+
76+
if not os.path.isdir(libdir):
77+
# No embedded library directory, probably not a wheel installation.
78+
return plugins
79+
80+
resolved = []
81+
for plugin in plugins.split(paths_sep):
82+
if '/' in plugin or '\\' in plugin:
83+
# Path specified, leave unchanged
84+
resolved.append(plugin)
85+
continue
86+
87+
# See if the plugin can be found in the wheel's
88+
# embedded library directory.
89+
# The user might not have supplied a file extension, so try both.
90+
good = None
91+
for file in [plugin, plugin + ext]:
92+
fpath = os.path.join(libdir, file)
93+
if os.path.isfile(fpath):
94+
good = fpath
95+
break
96+
97+
if good is not None:
98+
resolved.append(good)
99+
else:
100+
resolved.append(plugin)
101+
102+
return paths_sep.join(resolved)

0 commit comments

Comments
 (0)