From: CSBVision Date: Wed, 14 Apr 2021 10:05:53 +0000 (+0200) Subject: Update __init__.py to support symbolic links X-Git-Tag: submit/tizen/20220120.021815~1^2~1^2~63^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec32061f5fc63880727b2d252294412b2e024c54;p=platform%2Fupstream%2Fopencv.git Update __init__.py to support symbolic links Currently, the LOADER_DIR is set as os.path.dirname(os.path.abspath(__file__)). This does not point to the true library path if the cv2 folder is symlinked into the Python package directory such that importing cv2 under Python fails. The proposed change only resolves symbolic links correctly by calling os.path.realpath(__file__) first and does not change anything if __file__ contains no symbolic link. --- diff --git a/modules/python/package/cv2/__init__.py b/modules/python/package/cv2/__init__.py index 940ac65732..de70872839 100644 --- a/modules/python/package/cv2/__init__.py +++ b/modules/python/package/cv2/__init__.py @@ -34,7 +34,7 @@ def bootstrap(): import platform if DEBUG: print('OpenCV loader: os.name="{}" platform.system()="{}"'.format(os.name, str(platform.system()))) - LOADER_DIR=os.path.dirname(os.path.abspath(__file__)) + LOADER_DIR = os.path.dirname(os.path.abspath(os.path.realpath(__file__))) PYTHON_EXTENSIONS_PATHS = [] BINARIES_PATHS = []