Decrease wheel package size (#287)

* Decrease wheel package size

* Decrease wheel package size

* Decrease wheel package size
This commit is contained in:
Jason
2022-09-27 18:02:34 +08:00
committed by GitHub
parent 108dfc0f3f
commit 1f35f2036e
4 changed files with 19 additions and 10 deletions

View File

@@ -300,7 +300,6 @@ if(ENABLE_VISION)
list(APPEND ALL_DEPLOY_SRCS ${DEPLOY_VISION_SRCS}) list(APPEND ALL_DEPLOY_SRCS ${DEPLOY_VISION_SRCS})
include_directories(${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/include) include_directories(${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/include)
include(${PROJECT_SOURCE_DIR}/cmake/opencv.cmake) include(${PROJECT_SOURCE_DIR}/cmake/opencv.cmake)
list(APPEND DEPEND_LIBS ${OpenCV_LIBS})
if(ENABLE_VISION_VISUALIZE) if(ENABLE_VISION_VISUALIZE)
add_definitions(-DENABLE_VISION_VISUALIZE) add_definitions(-DENABLE_VISION_VISUALIZE)

View File

@@ -134,6 +134,6 @@ else()
endif() endif()
find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR}) find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR})
include_directories(${OpenCV_INCLUDE_DIRS}) 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()
endif() endif()

View File

@@ -32,6 +32,18 @@ def process_on_linux(current_dir):
fd_libs.append(filename) fd_libs.append(filename)
third_libs_path = os.path.join(libs_path, "third_libs") 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 all_libs_paths = [third_libs_path] + user_specified_dirs
for path in all_libs_paths: for path in all_libs_paths:
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):

View File

@@ -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["WITH_GPU"] = os.getenv("WITH_GPU", "OFF")
setup_configs["BUILD_ON_JETSON"] = os.getenv("BUILD_ON_JETSON", "OFF") setup_configs["BUILD_ON_JETSON"] = os.getenv("BUILD_ON_JETSON", "OFF")
setup_configs["TRT_DIRECTORY"] = os.getenv("TRT_DIRECTORY", "UNDEFINED") setup_configs["TRT_DIRECTORY"] = os.getenv("TRT_DIRECTORY", "UNDEFINED")
setup_configs["CUDA_DIRECTORY"] = os.getenv("CUDA_DIRECTORY", setup_configs["CUDA_DIRECTORY"] = os.getenv("CUDA_DIRECTORY", "/usr/local/cuda")
"/usr/local/cuda")
setup_configs["LIBRARY_NAME"] = PACKAGE_NAME setup_configs["LIBRARY_NAME"] = PACKAGE_NAME
setup_configs["PY_LIBRARY_NAME"] = PACKAGE_NAME + "_main" setup_configs["PY_LIBRARY_NAME"] = PACKAGE_NAME + "_main"
setup_configs["OPENCV_DIRECTORY"] = os.getenv("OPENCV_DIRECTORY", "") setup_configs["OPENCV_DIRECTORY"] = os.getenv("OPENCV_DIRECTORY", "")
setup_configs["ORT_DIRECTORY"] = os.getenv("ORT_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" wheel_name = "fastdeploy-gpu-python"
if os.getenv("CMAKE_CXX_COMPILER", None) is not None: 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. # 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 # However going forward the recomemded way to is to set this to False\0
USE_MSVC_STATIC_RUNTIME = bool( USE_MSVC_STATIC_RUNTIME = bool(os.getenv('USE_MSVC_STATIC_RUNTIME', '1') == '1')
os.getenv('USE_MSVC_STATIC_RUNTIME', '1') == '1')
ONNX_NAMESPACE = os.getenv('ONNX_NAMESPACE', 'paddle2onnx') ONNX_NAMESPACE = os.getenv('ONNX_NAMESPACE', 'paddle2onnx')
################################################################################ ################################################################################
# Version # Version
@@ -120,8 +119,7 @@ assert CMAKE, 'Could not find "cmake" executable!'
@contextmanager @contextmanager
def cd(path): def cd(path):
if not os.path.isabs(path): if not os.path.isabs(path):
raise RuntimeError('Can only cd to absolute path, got: {}'.format( raise RuntimeError('Can only cd to absolute path, got: {}'.format(path))
path))
orig_path = os.getcwd() orig_path = os.getcwd()
os.chdir(path) os.chdir(path)
try: try:
@@ -394,7 +392,7 @@ else:
cmdclass=cmdclass, cmdclass=cmdclass,
packages=packages, packages=packages,
package_data=package_data, package_data=package_data,
include_package_data=True, include_package_data=False,
setup_requires=setup_requires, setup_requires=setup_requires,
extras_require=extras_require, extras_require=extras_require,
author='fastdeploy', author='fastdeploy',