diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e104fe37..2c4a5fd03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,7 +300,6 @@ if(ENABLE_VISION) list(APPEND ALL_DEPLOY_SRCS ${DEPLOY_VISION_SRCS}) include_directories(${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/include) include(${PROJECT_SOURCE_DIR}/cmake/opencv.cmake) - list(APPEND DEPEND_LIBS ${OpenCV_LIBS}) if(ENABLE_VISION_VISUALIZE) add_definitions(-DENABLE_VISION_VISUALIZE) diff --git a/cmake/opencv.cmake b/cmake/opencv.cmake index d2c2d320e..082bb771b 100644 --- a/cmake/opencv.cmake +++ b/cmake/opencv.cmake @@ -134,6 +134,6 @@ else() endif() find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR}) include_directories(${OpenCV_INCLUDE_DIRS}) - list(APPEND DEPEND_LIBS ${OpenCV_LIBS}) + list(APPEND DEPEND_LIBS opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs) endif() endif() diff --git a/python/scripts/process_libraries.py.in b/python/scripts/process_libraries.py.in index d568c7884..c574ea367 100644 --- a/python/scripts/process_libraries.py.in +++ b/python/scripts/process_libraries.py.in @@ -32,6 +32,18 @@ def process_on_linux(current_dir): fd_libs.append(filename) third_libs_path = os.path.join(libs_path, "third_libs") + + # remove some useless opencv file in python wheels to decrease package size + if os.path.exists(os.path.join(third_libs_path, "opencv")): + for root, dirs, files in os.walk(os.path.join(third_libs_path, "opencv")): + for f in files: + items = f.strip().split('.') + if len(items) != 4: + os.remove(os.path.join(root, f)) + continue + if items[0].strip() not in ["libopencv_highgui", "libopencv_videoio", "libopencv_imgcodecs", "libopencv_imgproc", "libopencv_core"]: + os.remove(os.path.join(root, f)) + all_libs_paths = [third_libs_path] + user_specified_dirs for path in all_libs_paths: for root, dirs, files in os.walk(path): diff --git a/python/setup.py b/python/setup.py index a09972327..1b0311df4 100644 --- a/python/setup.py +++ b/python/setup.py @@ -59,14 +59,14 @@ setup_configs["ENABLE_TRT_BACKEND"] = os.getenv("ENABLE_TRT_BACKEND", "OFF") setup_configs["WITH_GPU"] = os.getenv("WITH_GPU", "OFF") setup_configs["BUILD_ON_JETSON"] = os.getenv("BUILD_ON_JETSON", "OFF") setup_configs["TRT_DIRECTORY"] = os.getenv("TRT_DIRECTORY", "UNDEFINED") -setup_configs["CUDA_DIRECTORY"] = os.getenv("CUDA_DIRECTORY", - "/usr/local/cuda") +setup_configs["CUDA_DIRECTORY"] = os.getenv("CUDA_DIRECTORY", "/usr/local/cuda") setup_configs["LIBRARY_NAME"] = PACKAGE_NAME setup_configs["PY_LIBRARY_NAME"] = PACKAGE_NAME + "_main" setup_configs["OPENCV_DIRECTORY"] = os.getenv("OPENCV_DIRECTORY", "") setup_configs["ORT_DIRECTORY"] = os.getenv("ORT_DIRECTORY", "") -if setup_configs["WITH_GPU"] == "ON" or setup_configs["BUILD_ON_JETSON"] == "ON": +if setup_configs["WITH_GPU"] == "ON" or setup_configs[ + "BUILD_ON_JETSON"] == "ON": wheel_name = "fastdeploy-gpu-python" if os.getenv("CMAKE_CXX_COMPILER", None) is not None: @@ -89,8 +89,7 @@ extras_require = {} # Default value is set to TRUE\1 to keep the settings same as the current ones. # However going forward the recomemded way to is to set this to False\0 -USE_MSVC_STATIC_RUNTIME = bool( - os.getenv('USE_MSVC_STATIC_RUNTIME', '1') == '1') +USE_MSVC_STATIC_RUNTIME = bool(os.getenv('USE_MSVC_STATIC_RUNTIME', '1') == '1') ONNX_NAMESPACE = os.getenv('ONNX_NAMESPACE', 'paddle2onnx') ################################################################################ # Version @@ -120,8 +119,7 @@ assert CMAKE, 'Could not find "cmake" executable!' @contextmanager def cd(path): if not os.path.isabs(path): - raise RuntimeError('Can only cd to absolute path, got: {}'.format( - path)) + raise RuntimeError('Can only cd to absolute path, got: {}'.format(path)) orig_path = os.getcwd() os.chdir(path) try: @@ -394,7 +392,7 @@ else: cmdclass=cmdclass, packages=packages, package_data=package_data, - include_package_data=True, + include_package_data=False, setup_requires=setup_requires, extras_require=extras_require, author='fastdeploy',