From e482e747f6715d56b3cf6b220c5447de95858bee Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Mon, 4 Jul 2016 19:43:11 +0530 Subject: Share gluster package namespace Problem: If both gluster-swift and libgfapi-python are installed on the same system, only one could be imported at a time. >>> from gluster import swift >>> from gluster import gfapi Traceback (most recent call last): File "", line 1, in ImportError: cannot import name gfapi Fix: Allow sharing of 'gluster' namespace among Python packages that use them. This was discussed and implemented for libgfapi-python project (http://review.gluster.org/#/c/9668/) but hadn't been done so far for other Python projects that use 'gluster' namespace. This change does it for gluster-swift. Refer: https://docs.python.org/2.7/library/pkgutil.html#pkgutil.extend_path https://stackoverflow.com/questions/1675734 Change-Id: Ic6de294325a065d606604179a7ab84721dd401e0 Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/14855 Reviewed-by: Niels de Vos Reviewed-by: Thiago da Silva Tested-by: Thiago da Silva --- gluster/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gluster/__init__.py b/gluster/__init__.py index e69de29..e26f727 100644 --- a/gluster/__init__.py +++ b/gluster/__init__.py @@ -0,0 +1,18 @@ +# Copyright (c) 2016 Red Hat, Inc. +# +# Licensed 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. + +# Share gluster namespace +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) -- cgit