code: def build_wheel(
      wheel_directory: str,
      config_settings: Optional[Dict[str, Any]] = None,
      metadata_directory: Optional[str] = None,
  ) -> str:
      """Build a wheel"""
      logger = logging.getLogger("xgboost.packager.build_wheel")
  
      build_config = BuildConfiguration()
      build_config.update(config_settings)
      logger.info(
          "Parsed build configuration: %s",
          dataclasses.asdict(build_config),
      )
  
      # Create tempdir with Python package + libxgboost
      with tempfile.TemporaryDirectory() as td:
          td_path = pathlib.Path(td)
          build_dir = td_path / "libbuild"
          build_dir.mkdir()
  
          workspace = td_path / "whl_workspace"
          workspace.mkdir()
          logger.info(
              "Copying project files to temporary directory %s",
              str(workspace),
          )
  
          copy_with_logging(
              TOPLEVEL_DIR / "pyproject.toml", workspace, logger=logger
          )
          copy_with_logging(
              TOPLEVEL_DIR / "hatch_build.py", workspace, logger=logger
          )
          copy_with_logging(
              TOPLEVEL_DIR / "README.rst", workspace, logger=logger
          )
  
          pkg_path = workspace / "xgboost"
          copytree_with_logging(
              TOPLEVEL_DIR / "xgboost", pkg_path, logger=logger
          )
          lib_path = pkg_path / "lib"
          lib_path.mkdir()
          libxgboost = locate_or_build_libxgboost(
              TOPLEVEL_DIR,
              build_dir=build_dir,
              build_config=build_config,
          )
          if not build_config.use_system_libxgboost:
              copy_with_logging(libxgboost, lib_path, logger=logger)
  
          with cd(workspace):
              wheel_name = hatchling.build.build_wheel(
                  wheel_directory, config_settings, metadata_directory
              )
      return wheel_name
  
file_path: xgboost/python-package/packager/pep517.py
imports: import dataclasses
  import logging
  import os
  import pathlib
  import tempfile
  from contextlib import contextmanager
  from typing import Any, Dict, Iterator, Optional, Union
  import hatchling.build
  from .build_config import BuildConfiguration
  from .nativelib import locate_local_libxgboost, locate_or_build_libxgboost
  from .sdist import copy_cpp_src_tree
  from .util import copy_with_logging, copytree_with_logging
label_desc: Use image node_id 2 for calling a global function with example usage: build_wheel(wheel_directory, config_settings, metadata_directory) and returns: wheel_name