From e8946968e380bbb9f36b898228d34f4309f17907 Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 23 Mar 2020 08:32:37 +0530 Subject: [PATCH 1/3] Fixes for python3 executables not detecting correctly in cmake. (patch by @abhiTronix) --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d9bae544..0145d02d 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ import subprocess import re import sysconfig +from sysconfig import get_paths as gp def main(): @@ -103,7 +104,8 @@ def main(): ]) + [ # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3 "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable, - "-DPYTHON3_EXECUTABLE=%s" % sys.executable, + "-DPYTHON3_LIBRARY=%s" % os.path.join('/usr/lib/x86_64-linux-gnu/', sysconfig.get_config_var('LDLIBRARY')), + "-DPYTHON3_INCLUDE_DIR=%s" % gp()['include'], "-DBUILD_opencv_python3=ON", "-DBUILD_opencv_python2=OFF", From 1eb662afd49f2c5619c5adcce89be43cfb4ca187 Mon Sep 17 00:00:00 2001 From: Abhishek Thakur Date: Mon, 23 Mar 2020 05:25:32 +0530 Subject: [PATCH 2/3] Added additional patch for correct OS-specific python libs detection --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0145d02d..5c0c6561 100644 --- a/setup.py +++ b/setup.py @@ -104,7 +104,6 @@ def main(): ]) + [ # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3 "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable, - "-DPYTHON3_LIBRARY=%s" % os.path.join('/usr/lib/x86_64-linux-gnu/', sysconfig.get_config_var('LDLIBRARY')), "-DPYTHON3_INCLUDE_DIR=%s" % gp()['include'], "-DBUILD_opencv_python3=ON", "-DBUILD_opencv_python2=OFF", @@ -124,7 +123,10 @@ def main(): "-DBUILD_TESTS=OFF", "-DBUILD_PERF_TESTS=OFF", "-DBUILD_DOCS=OFF" - ] + (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else []) + ] + + # patch for OS-specific python libs + (["-DPYTHON3_LIBRARY=%s" % os.path.join(*[sysconfig.get_config_var('BINDIR'), "libs","python{}.lib".format("".join(str(v) for v in sys.version_info[:2]))])] if sys.platform.startswith('win') else ["-DPYTHON3_LIBRARY=%s" % os.path.join('/usr/lib/x86_64-linux-gnu/', sysconfig.get_config_var('LDLIBRARY'))]) + + (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else []) # OS-specific components if sys.platform.startswith('linux') and not build_headless: From de7216037b167553e8e3b4cfc09cbd32020e4ff2 Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 23 Mar 2020 12:37:00 +0530 Subject: [PATCH 3/3] Fixed syntax errors --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 5c0c6561..3005e8b6 100644 --- a/setup.py +++ b/setup.py @@ -123,9 +123,8 @@ def main(): "-DBUILD_TESTS=OFF", "-DBUILD_PERF_TESTS=OFF", "-DBUILD_DOCS=OFF" - ] + - # patch for OS-specific python libs - (["-DPYTHON3_LIBRARY=%s" % os.path.join(*[sysconfig.get_config_var('BINDIR'), "libs","python{}.lib".format("".join(str(v) for v in sys.version_info[:2]))])] if sys.platform.startswith('win') else ["-DPYTHON3_LIBRARY=%s" % os.path.join('/usr/lib/x86_64-linux-gnu/', sysconfig.get_config_var('LDLIBRARY'))]) + + ] + \ + (["-DPYTHON3_LIBRARY=%s" % os.path.join(*[sysconfig.get_config_var('BINDIR'), "libs","python{}.lib".format("".join(str(v) for v in sys.version_info[:2]))])] if sys.platform.startswith('win') else ["-DPYTHON3_LIBRARY=%s" % os.path.join('/usr/lib/x86_64-linux-gnu/', sysconfig.get_config_var('LDLIBRARY'))]) + \ (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else []) # OS-specific components