20
20
from setuptools .command .build_clib import build_clib
21
21
from setuptools .command .install import install
22
22
from setuptools .command .build import build
23
+ from setuptools .command .bdist_wheel import bdist_wheel
23
24
from setuptools .errors import SetupError
24
25
25
26
WHEEL_PACKAGE_DIR = "openvino"
42
43
ARCH = "riscv64"
43
44
44
45
# The following variables can be defined in environment or .env file
45
- SCRIPT_DIR = Path (__file__ ).resolve ().parents [ 0 ]
46
+ SCRIPT_DIR = Path (__file__ ).resolve ().parent
46
47
WORKING_DIR = Path .cwd ()
47
- BUILD_BASE = f"{ WORKING_DIR } / build_{ PYTHON_VERSION } "
48
- OPENVINO_SOURCE_DIR = SCRIPT_DIR . parents [ 3 ]
49
- OPENVINO_BINARY_DIR = os .getenv ("OPENVINO_BINARY_DIR" )
48
+ BUILD_BASE = f"build_{ PYTHON_VERSION } "
49
+ OPENVINO_SOURCE_DIR = os . getenv ( "OPENVINO_SOURCE_DIR" , SCRIPT_DIR )
50
+ OPENVINO_BINARY_DIR = os .getenv ("OPENVINO_BINARY_DIR" , f' { OPENVINO_SOURCE_DIR } /build_wheel' )
50
51
OPENVINO_PYTHON_BINARY_DIR = os .getenv ("OPENVINO_PYTHON_BINARY_DIR" , "python_build" )
51
52
CONFIG = os .getenv ("BUILD_TYPE" , "Release" )
52
- OV_RUNTIME_LIBS_DIR = os .getenv ("OV_RUNTIME_LIBS_DIR" , f"runtime/{ LIBS_DIR } /{ ARCH } / { CONFIG } " )
53
+ OV_RUNTIME_LIBS_DIR = os .getenv ("OV_RUNTIME_LIBS_DIR" , f"runtime/{ LIBS_DIR } /{ ARCH } " )
53
54
TBB_LIBS_DIR = os .getenv ("TBB_LIBS_DIR" , f"runtime/3rdparty/tbb/{ LIBS_DIR } " )
54
55
PUGIXML_LIBS_DIR = os .getenv ("PUGIXML_LIBS_DIR" , f"runtime/3rdparty/pugixml/{ LIBS_DIR } " )
55
56
PY_PACKAGES_DIR = os .getenv ("PY_PACKAGES_DIR" , "python" )
@@ -285,26 +286,22 @@ def cmake_build_and_install(self, install_cfg):
285
286
"""Runs cmake (configure, build and install) if artfiacts are not already built / installed."""
286
287
plat_specifier = ".{0}-{1}.{2}" .format (self .plat_name , * sys .version_info [:2 ])
287
288
self .build_temp = os .path .join (self .build_base , "temp" + plat_specifier )
288
- self .announce (f"Create build directory: { self .build_temp } " , level = 3 )
289
+ self .announce (f"Create build directory: { self .build_temp } " , level = log . INFO )
289
290
# build some components which have not been built yet
290
291
for comp , comp_data in install_cfg .items ():
291
292
cpack_comp_name = comp_data .get ("name" )
292
293
source_dir = comp_data .get ("source_dir" , OPENVINO_SOURCE_DIR )
293
294
binary_dir = comp_data .get ("binary_dir" , OPENVINO_BINARY_DIR )
294
295
install_dir = comp_data .get ("install_dir" )
295
296
prefix = comp_data .get ("prefix" )
296
-
297
+
297
298
# perform installation steps if we are not given a full path
298
299
if not os .path .isabs (install_dir ):
299
300
# install_dir is just a sub-dir after install prefix, let's make a full path
300
- comp_data ["install_dir" ] = os .path .join (prefix , install_dir )
301
-
302
- # even perform a build in case of binary directory does not exist
303
- binary_dir = binary_dir if os .path .isabs (binary_dir ) else os .path .join (self .build_temp , binary_dir )
304
-
305
301
if not os .path .exists (binary_dir ):
302
+ # even perform a build in case of binary directory does not exist
306
303
binary_dir = os .path .join (self .build_temp , binary_dir )
307
- self .announce (f"Configuring { comp } cmake project" , level = 3 )
304
+ self .announce (f"Configuring { comp } cmake project" , level = log . INFO )
308
305
self .spawn (["cmake" ,
309
306
f"-DOpenVINODeveloperPackage_DIR={ OPENVINO_BINARY_DIR } " ,
310
307
f"-DPython3_EXECUTABLE={ sys .executable } " ,
@@ -316,12 +313,12 @@ def cmake_build_and_install(self, install_cfg):
316
313
"-S" , source_dir ,
317
314
"-B" , binary_dir ])
318
315
319
- self .announce (f"Building { comp } project" , level = 3 )
316
+ self .announce (f"Building { comp } project" , level = log . INFO )
320
317
self .spawn (["cmake" , "--build" , binary_dir ,
321
318
"--config" , CONFIG ,
322
319
"--parallel" , str (self .jobs )])
323
320
324
- self .announce (f"Installing { comp } " , level = 3 )
321
+ self .announce (f"Installing { comp } " , level = log . INFO )
325
322
self .spawn (["cmake" , "--install" , binary_dir ,
326
323
"--prefix" , prefix ,
327
324
"--config" , CONFIG ,
@@ -351,7 +348,6 @@ def run(self):
351
348
(dst / path_rel .parent ).mkdir (exist_ok = True , parents = True )
352
349
copyfile (path , dst / path_rel )
353
350
354
-
355
351
class PrepareLibs (build_clib ):
356
352
"""Prepares prebuilt libraries.
357
353
@@ -371,7 +367,7 @@ def run(self):
371
367
def post_install (self , install_cfg ):
372
368
"""Install prebuilt libraries to the temp directories, set rpath."""
373
369
for comp , comp_data in install_cfg .items ():
374
- install_dir = comp_data .get ("install_dir" )
370
+ install_dir = os . path . join ( comp_data .get ("prefix" ), comp_data . get ( " install_dir") )
375
371
376
372
# we need to resolve symlinks before setting rpath to avoid doing it multiple times
377
373
install_dir_path = Path (install_dir )
@@ -425,11 +421,11 @@ def resolve_symlinks(self, local_base_dir: Path):
425
421
link_file_name_new = os .path .basename (symlink )
426
422
if len (link_file_name_new ) > len (link_file_name_old ):
427
423
# replace libX.so/libX.dylib with libX.so.Y/libX.Y.dylib
428
- self .announce (f"Unlink symlink { file_dict [real_name ]} , use { symlink } instead" , level = 3 )
424
+ self .announce (f"Unlink symlink { file_dict [real_name ]} , use { symlink } instead" , level = log . INFO )
429
425
os .unlink (file_dict [real_name ])
430
426
file_dict [real_name ] = symlink
431
427
else :
432
- self .announce (f"Unlink symlink { symlink } , use { file_dict [real_name ]} instead" , level = 3 )
428
+ self .announce (f"Unlink symlink { symlink } , use { file_dict [real_name ]} instead" , level = log . INFO )
433
429
os .unlink (symlink )
434
430
else :
435
431
file_dict [real_name ] = symlink
@@ -440,7 +436,7 @@ def resolve_symlinks(self, local_base_dir: Path):
440
436
for real_name , symlink in file_dict .items ():
441
437
os .unlink (symlink )
442
438
os .rename (real_name , symlink )
443
- self .announce (f"Resolved symlink { symlink } as { real_name } " , level = 3 )
439
+ self .announce (f"Resolved symlink { symlink } as { real_name } " , level = log . INFO )
444
440
445
441
def copy_package_libs (self , src_dirs ):
446
442
"""Collect package data files (clibs and other plugin support files) from preinstalled dirs and put all runtime libraries to the subpackage."""
@@ -465,10 +461,10 @@ def copy_package_libs(self, src_dirs):
465
461
if file_path .is_file () and not is_blacklisted (file_name , blacklist_patterns ):
466
462
dst_file = os .path .join (package_clibs_dir , file_name )
467
463
copyfile (file_path , dst_file )
468
- self .announce (f"Copy { file_path } to { dst_file } " , level = 3 )
464
+ self .announce (f"Copy { file_path } to { dst_file } " , level = log . INFO )
469
465
470
466
if Path (package_clibs_dir ).exists ():
471
- self .announce (f"Adding { WHEEL_LIBS_PACKAGE } package" , level = 3 )
467
+ self .announce (f"Adding { WHEEL_LIBS_PACKAGE } package" , level = log . INFO )
472
468
packages .append (WHEEL_LIBS_PACKAGE )
473
469
package_data .update ({WHEEL_LIBS_PACKAGE : ["*" ]})
474
470
@@ -518,16 +514,16 @@ def copy_package_data(self, src_dirs):
518
514
if file_path .is_file () and not is_blacklisted (file_name , blacklist_patterns ):
519
515
dst_file = os .path .join (package_clibs_dir , file_name )
520
516
move (file_path , dst_file )
521
- self .announce (f"Move { file_path } to { dst_file } " , level = 3 )
517
+ self .announce (f"Move { file_path } to { dst_file } " , level = log . INFO )
522
518
523
519
# collect all cmake files in one directory
524
520
for file_path in Path (src ).rglob ("*.cmake" ):
525
521
file_name = os .path .basename (file_path )
526
522
if file_path .is_file () and not is_blacklisted (file_name , blacklist_patterns ):
527
523
dst_file = os .path .join (package_cmake_dir , file_name )
528
- self .announce (f"Move { file_path } to { dst_file } " , level = 3 )
524
+ self .announce (f"Move { file_path } to { dst_file } " , level = log . INFO )
529
525
move (file_path , dst_file )
530
- self .announce ("Patch cmake configurations" , level = 3 )
526
+ self .announce ("Patch cmake configurations" , level = log . INFO )
531
527
replace_strings_in_file (dst_file ,
532
528
openvino_replacements if file_name .startswith ("OpenVINO" ) else tbb_replacements )
533
529
@@ -592,12 +588,34 @@ def run(self):
592
588
593
589
594
590
class CustomInstall (install ):
595
- """Enable build_clib during the installation."""
596
-
591
+ """Custom install command."""
597
592
def run (self ):
593
+ """Enable build_clib during the installation."""
598
594
self .run_command ("build" )
599
- install .run (self )
595
+ super ().run ()
596
+
597
+
598
+ class CustomBdistWheel (bdist_wheel ):
599
+ """Custom bdist_wheel command."""
600
+ def initialize_options (self ):
601
+ """Set default values for all the options that this command supports."""
602
+ super ().initialize_options ()
600
603
604
+ def finalize_options (self ):
605
+ """Set final values for all the options that this command supports."""
606
+ super ().finalize_options ()
607
+
608
+ platform_tag = os .getenv ("PLATFORM_TAG" )
609
+ if platform_tag :
610
+ self .plat_name = platform_tag
611
+ self .plat_name_supplied = True
612
+
613
+ build_number = os .getenv ("WHEEL_BUILD" )
614
+ if build_number :
615
+ self .build_number = build_number
616
+
617
+ def run (self ):
618
+ super ().run ()
601
619
602
620
class CustomClean (Command ):
603
621
"""Clean up staging directories."""
@@ -613,7 +631,7 @@ def finalize_options(self):
613
631
def clean_install_prefix (self , install_cfg ):
614
632
for comp , comp_data in install_cfg .items ():
615
633
install_prefix = comp_data .get ("prefix" )
616
- self .announce (f"Cleaning { comp } : { install_prefix } " , level = 3 )
634
+ self .announce (f"Cleaning { comp } : { install_prefix } " , level = log . INFO )
617
635
if os .path .exists (install_prefix ):
618
636
rmtree (install_prefix )
619
637
@@ -723,13 +741,6 @@ def get_description(desc_file_path):
723
741
return description
724
742
725
743
726
- def get_install_requires (requirements_file_path ):
727
- """Read dependencies from requirements.txt."""
728
- with open (requirements_file_path , "r" , encoding = "utf-8" ) as fstream :
729
- install_requirements = fstream .read ()
730
- return install_requirements
731
-
732
-
733
744
def get_install_dirs_list (install_cfg ):
734
745
"""Collect all available directories with clibs or python extensions."""
735
746
install_dirs = []
@@ -784,8 +795,8 @@ def concat_files(input_files, output_file):
784
795
ext_modules = find_prebuilt_extensions (get_install_dirs_list (PY_INSTALL_CFG ))
785
796
entry_points = find_entry_points (PY_INSTALL_CFG )
786
797
787
- long_description_md = OPENVINO_SOURCE_DIR / "docs" / "dev" / "pypi_publish" / "pypi-openvino-rt.md"
788
- md_files = [long_description_md , OPENVINO_SOURCE_DIR / "docs" / "dev" / "pypi_publish" / "pre-release-note.md" ]
798
+ long_description_md = Path ( OPENVINO_SOURCE_DIR ) / "docs" / "dev" / "pypi_publish" / "pypi-openvino-rt.md"
799
+ md_files = [long_description_md , Path ( OPENVINO_SOURCE_DIR ) / "docs" / "dev" / "pypi_publish" / "pre-release-note.md" ]
789
800
docs_url = "https://docs.openvino.ai/2023.0/index.html"
790
801
791
802
if os .getenv ("CI_BUILD_DEV_TAG" ):
@@ -797,20 +808,15 @@ def concat_files(input_files, output_file):
797
808
798
809
setup (
799
810
name = "openvino" ,
800
- version = WHEEL_VERSION ,
801
- build = os .getenv ("WHEEL_BUILD" , "000" ),
802
- author_email = "openvino@intel.com" ,
803
- license = "OSI Approved :: Apache Software License" ,
804
- author = "Intel(R) Corporation" ,
805
- description = "OpenVINO(TM) Runtime" ,
806
- install_requires = get_install_requires (SCRIPT_DIR .parents [0 ] / "requirements.txt" ),
811
+ version = f'{ WHEEL_VERSION } ' ,
807
812
long_description = get_description (long_description_md ),
808
813
long_description_content_type = "text/markdown" ,
809
814
download_url = "https://github.com/openvinotoolkit/openvino/releases" ,
810
815
url = docs_url ,
811
816
entry_points = entry_points ,
812
817
cmdclass = {
813
818
"build" : CustomBuild ,
819
+ "bdist_wheel" : CustomBdistWheel ,
814
820
"install" : CustomInstall ,
815
821
"build_clib" : PrepareLibs ,
816
822
"build_ext" : CopyExt ,
0 commit comments