Skip to content

Commit a255e30

Browse files
authored
[PYPI] Include static libs on windows (openvinotoolkit#25156)
### Details: - Fixed regexp for patching cmake files - copy static libs on windows ### Tickets: - *ticket-id*
1 parent d3b3835 commit a255e30

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

src/bindings/c/src/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ export(TARGETS ${TARGET_NAME} NAMESPACE openvino::
5050
ov_cpack_add_component(${OV_CPACK_COMP_CORE_C} HIDDEN)
5151
ov_cpack_add_component(${OV_CPACK_COMP_CORE_C_DEV} HIDDEN)
5252

53+
if(BUILD_SHARED_LIBS)
54+
set(archive_comp CORE_C_DEV)
55+
else()
56+
set(archive_comp CORE_C)
57+
endif()
58+
5359
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets
5460
RUNTIME DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} ${OV_CPACK_COMP_CORE_C_EXCLUDE_ALL}
55-
ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} ${OV_CPACK_COMP_CORE_C_EXCLUDE_ALL}
61+
ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_${archive_comp}} ${OV_CPACK_COMP_${archive_comp}_EXCLUDE_ALL}
5662
LIBRARY DESTINATION ${OV_CPACK_LIBRARYDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} ${OV_CPACK_COMP_CORE_C_EXCLUDE_ALL}
5763
NAMELINK_COMPONENT ${OV_CPACK_COMP_LINKS} ${OV_CPACK_COMP_LINKS_EXCLUDE_ALL}
5864
INCLUDES DESTINATION ${OV_CPACK_INCLUDEDIR})

src/bindings/python/wheel/setup.py

+30-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import logging as log
1515
from fnmatch import fnmatchcase
1616
from pathlib import Path
17-
from shutil import copyfile, rmtree
17+
from shutil import copyfile, rmtree, move
1818
from setuptools import setup, find_namespace_packages, Extension, Command
1919
from setuptools.command.build_ext import build_ext
2020
from setuptools.command.build_clib import build_clib
@@ -175,7 +175,14 @@
175175
DATA_INSTALL_CFG = {
176176
"core_dev": {
177177
"name": "core_dev",
178-
"prefix": f"{BUILD_BASE}/libs.dev",
178+
"prefix": f"{BUILD_BASE}/libs.core.dev",
179+
"install_dir": "runtime",
180+
"binary_dir": OPENVINO_BINARY_DIR,
181+
"source_dir": OPENVINO_SOURCE_DIR
182+
},
183+
"core_c_dev": {
184+
"name": "core_c_dev",
185+
"prefix": f"{BUILD_BASE}/libs.core_c.dev",
179186
"install_dir": "runtime",
180187
"binary_dir": OPENVINO_BINARY_DIR,
181188
"source_dir": OPENVINO_SOURCE_DIR
@@ -422,7 +429,7 @@ def copy_package_libs(self, src_dirs):
422429
for src_dir in src_dirs:
423430
# additional blacklist filter, just to fix cmake install issues
424431
blacklist_patterns = [ # static libraries and PBD files
425-
"^.*\\.a$", "^.*\\.lib$", "^.*\\.pdb$",
432+
"^.*\\.a$", "^.*\\.pdb$",
426433
# TBB debug libraries
427434
"^.*_debug\\.dll$", "^.*_debug\\.\\d*\\.dylib$", "^.*_debug\\.so\\.\\d*$",
428435
# hwloc static libs on Windows
@@ -453,24 +460,37 @@ def copy_package_data(self, src_dirs):
453460
"""Collect package data files from preinstalled dirs and put to the subpackage."""
454461
package_dir = os.path.join(PACKAGE_DIR, WHEEL_PACKAGE_DIR)
455462
os.makedirs(package_dir, exist_ok=True)
463+
package_clibs_dir = os.path.join(PACKAGE_DIR, WHEEL_LIBS_INSTALL_DIR)
464+
os.makedirs(package_clibs_dir, exist_ok=True)
456465

457466
replacements = {
458467
# change the path where the libraries are installed (runtime/lib/intel64/Release -> openvino/libs)
459-
f"{OV_RUNTIME_LIBS_DIR}": f"{WHEEL_LIBS_INSTALL_DIR}",
468+
r"({_IMPORT_PREFIX})\/(.*)\/(.*.[lib|dylib|so|dll])": rf"\1/{WHEEL_LIBS_INSTALL_DIR}/\3",
460469
# change the path where the include files are installed (runtime/include -> openvino/include)
461470
r"({_IMPORT_PREFIX})\/(.*)\/(include)": rf"\1/{WHEEL_PACKAGE_DIR}/\3",
462-
# changed the lib version (2024.3.0 -> 2430)
463-
r"(.so).(\d\d)(\d\d).(\d+).(\d+)": r"\1.\3\4\5"
471+
# change the libs versions (so.2024.3.0 -> so.2430 or 2024.3.0.dylib -> 2430.dylib)
472+
r"(.so)?.(\d\d)(\d\d).(\d+).(\d+)(.dylib)?": r"\1.\3\4\5\6",
464473
}
465474

466475
for src_dir in src_dirs:
467476
src, dst = Path(src_dir), Path(package_dir)
468-
shutil.copytree(src, dst, dirs_exist_ok=True)
469477

470-
# patch cmake configurations
471-
for file_path in Path(dst).rglob("*.cmake"):
478+
# move the static libs to the directory with the shared libraries
479+
for file_path in Path(src).rglob("*.lib"):
480+
file_name = os.path.basename(file_path)
472481
if file_path.is_file():
473-
replace_strings_in_file(file_path, replacements)
482+
dst_file = os.path.join(package_clibs_dir, file_name)
483+
move(file_path, dst_file)
484+
self.announce(f"Move {file_path} to {dst_file}", level=3)
485+
486+
if os.path.isdir(src) and os.listdir(src):
487+
# copy the rest of the files to the package directly
488+
shutil.copytree(src, dst, dirs_exist_ok=True)
489+
490+
# patch cmake configurations
491+
for file_path in Path(dst).rglob("*.cmake"):
492+
if file_path.is_file():
493+
replace_strings_in_file(file_path, replacements)
474494

475495

476496
def copy_file(src, dst, verbose=False, dry_run=False):

0 commit comments

Comments
 (0)