@@ -108,12 +108,32 @@ def main():
108108 # Naming conventions vary so widely between versions and OSes
109109 # had to give up on checking them.
110110 [
111- "python/cv2[^/]*%(ext)s"
112- % {"ext" : re .escape (sysconfig .get_config_var ("EXT_SUFFIX" ))}
111+ "python/cv2/python-%s.%s/cv2[^/]*%s"
112+ % (sys .version_info [0 ], sys .version_info [1 ], re .escape (sysconfig .get_config_var ("EXT_SUFFIX" )))
113+ ]
114+ +
115+ [
116+ r"python/cv2/__init__.py"
117+ ]
118+ +
119+ [
120+ r"python/cv2/.*config.*.py"
113121 ],
114122 "cv2.data" : [ # OPENCV_OTHER_INSTALL_PATH
115123 ("etc" if os .name == "nt" else "share/opencv4" ) + r"/haarcascades/.*\.xml"
116124 ],
125+ "cv2.gapi" : [
126+ "python/cv2" + r"/gapi/.*\.py"
127+ ],
128+ "cv2.mat_wrapper" : [
129+ "python/cv2" + r"/mat_wrapper/.*\.py"
130+ ],
131+ "cv2.misc" : [
132+ "python/cv2" + r"/misc/.*\.py"
133+ ],
134+ "cv2.utils" : [
135+ "python/cv2" + r"/utils/.*\.py"
136+ ],
117137 }
118138
119139 # Files in sourcetree outside package dir that should be copied to package.
@@ -137,8 +157,6 @@ def main():
137157 "-DBUILD_opencv_python2=OFF" ,
138158 # Disable the Java build by default as it is not needed
139159 "-DBUILD_opencv_java=%s" % build_java ,
140- # When off, adds __init__.py and a few more helper .py's. We use our own helper files with a different structure.
141- "-DOPENCV_SKIP_PYTHON_LOADER=ON" ,
142160 # Relative dir to install the built module to in the build tree.
143161 # The default is generated from sysconfig, we'd rather have a constant for simplicity
144162 "-DOPENCV_PYTHON3_INSTALL_PATH=python" ,
@@ -358,6 +376,13 @@ def _classify_installed_files_override(
358376
359377 print ("Copying files from CMake output" )
360378
379+ # add lines from the old __init__.py file to the config file
380+ with open ('scripts/__init__.py' , 'r' ) as custom_init :
381+ custom_init_data = custom_init .read ()
382+ with open ('%spython/cv2/config-%s.%s.py'
383+ % (cmake_install_dir , sys .version_info [0 ], sys .version_info [1 ]), 'w' ) as opencv_init_config :
384+ opencv_init_config .write (custom_init_data )
385+
361386 for package_name , relpaths_re in cls .package_paths_re .items ():
362387 package_dest_reldir = package_name .replace ("." , os .path .sep )
363388 for relpath_re in relpaths_re :
0 commit comments