MCPcopy Create free account
hub / github.com/catboost/catboost / make_wheel

Function make_wheel

catboost/python-package/mk_wheel.py:243–329  ·  view source on GitHub ↗
(wheel_name, pkg_name, ver, build_system, arc_root, dst_so_modules, should_build_widget)

Source from the content-addressed store, hash-verified

241
242
243def make_wheel(wheel_name, pkg_name, ver, build_system, arc_root, dst_so_modules, should_build_widget):
244 dir_path = tempfile.mkdtemp()
245 try:
246 # Create py files
247 os.makedirs(os.path.join(dir_path, pkg_name))
248
249 catboost_package_dir = os.path.join(arc_root, 'catboost/python-package')
250 for file_name in ['__init__.py', 'version.py', 'core.py', 'datasets.py', 'utils.py', 'eval', 'widget/__init__.py',
251 'widget/ipythonwidget.py','widget/metrics_plotter.py', 'widget/callbacks.py',
252 'metrics.py', 'monoforest.py', 'plot_helpers.py', 'text_processing.py']:
253 src = os.path.join(catboost_package_dir, 'catboost', file_name)
254 dst = os.path.join(dir_path, pkg_name, file_name)
255 if not os.path.exists(os.path.dirname(dst)):
256 os.makedirs(os.path.dirname(dst))
257
258 if os.path.isdir(src):
259 shutil.copytree(src, dst)
260 else:
261 shutil.copy(src, dst)
262
263 hnsw_package_dir = os.path.join(arc_root, 'library/python/hnsw/hnsw')
264 hnsw_dst_dir = os.path.join(dir_path, pkg_name, 'hnsw')
265 os.makedirs(hnsw_dst_dir)
266 for file_name in ['__init__.py', 'hnsw.py']:
267 src = os.path.join(hnsw_package_dir, file_name)
268 dst = os.path.join(hnsw_dst_dir, file_name)
269 shutil.copy(src, dst)
270
271 # Create so files
272 py_trait = PythonTrait(build_system, '', '', [])
273 for module_name, (built_so_path, dst_subdir) in dst_so_modules.items():
274 dst_so_name = py_trait.dst_so_name(module_name)
275 shutil.copy(built_so_path, os.path.join(dir_path, pkg_name, dst_subdir, dst_so_name))
276
277 # Create metadata
278 dist_info_dir = os.path.join(dir_path, '{}-{}.dist-info'.format(pkg_name, ver))
279 shutil.copytree(os.path.join(catboost_package_dir, 'for_mk_wheel', 'catboost.dist-info'), dist_info_dir)
280
281 def substitute_vars(file_path):
282 allow_to_write(file_path)
283 with open(file_path, 'r') as fm:
284 metadata = fm.read()
285 metadata = metadata.format(
286 pkg_name=pkg_name,
287 version=ver,
288 )
289 with open(file_path, 'w') as fm:
290 fm.write(metadata)
291
292 substitute_vars(os.path.join(dist_info_dir, 'METADATA'))
293 substitute_vars(os.path.join(dist_info_dir, 'top_level.txt'))
294
295 if should_build_widget:
296 data_dir = os.path.join(dir_path, '{}-{}.data'.format(pkg_name, ver), 'data')
297 widget_dir = os.path.join(catboost_package_dir, 'catboost', 'widget')
298 for file in ['extension.js', 'index.js']:
299 src = os.path.join(widget_dir, 'js', 'nbextension', file)
300 dst = os.path.join(data_dir, 'share', 'jupyter', 'nbextensions', 'catboost-widget', file)

Callers 1

buildFunction · 0.85

Calls 8

dst_so_nameMethod · 0.95
PythonTraitClass · 0.85
substitute_varsFunction · 0.85
make_recordFunction · 0.85
joinMethod · 0.45
copyMethod · 0.45
formatMethod · 0.45
moveMethod · 0.45

Tested by

no test coverage detected