File indexing completed on 2024-11-24 05:05:58
0001 """Metadata generation logic for source distributions. 0002 """ 0003 0004 import os 0005 0006 from pip._vendor.pep517.wrappers import Pep517HookCaller 0007 0008 from pip._internal.build_env import BuildEnvironment 0009 from pip._internal.exceptions import ( 0010 InstallationSubprocessError, 0011 MetadataGenerationFailed, 0012 ) 0013 from pip._internal.utils.subprocess import runner_with_spinner_message 0014 from pip._internal.utils.temp_dir import TempDirectory 0015 0016 0017 def generate_editable_metadata( 0018 build_env: BuildEnvironment, backend: Pep517HookCaller, details: str 0019 ) -> str: 0020 """Generate metadata using mechanisms described in PEP 660. 0021 0022 Returns the generated metadata directory. 0023 """ 0024 metadata_tmpdir = TempDirectory(kind="modern-metadata", globally_managed=True) 0025 0026 metadata_dir = metadata_tmpdir.path 0027 0028 with build_env: 0029 # Note that Pep517HookCaller implements a fallback for 0030 # prepare_metadata_for_build_wheel/editable, so we don't have to 0031 # consider the possibility that this hook doesn't exist. 0032 runner = runner_with_spinner_message( 0033 "Preparing editable metadata (pyproject.toml)" 0034 ) 0035 with backend.subprocess_runner(runner): 0036 try: 0037 distinfo_dir = backend.prepare_metadata_for_build_editable(metadata_dir) 0038 except InstallationSubprocessError as error: 0039 raise MetadataGenerationFailed(package_details=details) from error 0040 0041 return os.path.join(metadata_dir, distinfo_dir)