m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

783 lines
23 KiB

6 months ago
  1. import contextlib
  2. import errno
  3. import getpass
  4. import hashlib
  5. import io
  6. import logging
  7. import os
  8. import posixpath
  9. import shutil
  10. import stat
  11. import sys
  12. import sysconfig
  13. import urllib.parse
  14. from functools import partial
  15. from io import StringIO
  16. from itertools import filterfalse, tee, zip_longest
  17. from pathlib import Path
  18. from types import FunctionType, TracebackType
  19. from typing import (
  20. Any,
  21. BinaryIO,
  22. Callable,
  23. ContextManager,
  24. Dict,
  25. Generator,
  26. Iterable,
  27. Iterator,
  28. List,
  29. Optional,
  30. TextIO,
  31. Tuple,
  32. Type,
  33. TypeVar,
  34. Union,
  35. cast,
  36. )
  37. from pip._vendor.packaging.requirements import Requirement
  38. from pip._vendor.pyproject_hooks import BuildBackendHookCaller
  39. from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
  40. from pip import __version__
  41. from pip._internal.exceptions import CommandError, ExternallyManagedEnvironment
  42. from pip._internal.locations import get_major_minor_version
  43. from pip._internal.utils.compat import WINDOWS
  44. from pip._internal.utils.virtualenv import running_under_virtualenv
  45. __all__ = [
  46. "rmtree",
  47. "display_path",
  48. "backup_dir",
  49. "ask",
  50. "splitext",
  51. "format_size",
  52. "is_installable_dir",
  53. "normalize_path",
  54. "renames",
  55. "get_prog",
  56. "captured_stdout",
  57. "ensure_dir",
  58. "remove_auth_from_url",
  59. "check_externally_managed",
  60. "ConfiguredBuildBackendHookCaller",
  61. ]
  62. logger = logging.getLogger(__name__)
  63. T = TypeVar("T")
  64. ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
  65. VersionInfo = Tuple[int, int, int]
  66. NetlocTuple = Tuple[str, Tuple[Optional[str], Optional[str]]]
  67. OnExc = Callable[[FunctionType, Path, BaseException], Any]
  68. OnErr = Callable[[FunctionType, Path, ExcInfo], Any]
  69. def get_pip_version() -> str:
  70. pip_pkg_dir = os.path.join(os.path.dirname(__file__), "..", "..")
  71. pip_pkg_dir = os.path.abspath(pip_pkg_dir)
  72. return f"pip {__version__} from {pip_pkg_dir} (python {get_major_minor_version()})"
  73. def normalize_version_info(py_version_info: Tuple[int, ...]) -> Tuple[int, int, int]:
  74. """
  75. Convert a tuple of ints representing a Python version to one of length
  76. three.
  77. :param py_version_info: a tuple of ints representing a Python version,
  78. or None to specify no version. The tuple can have any length.
  79. :return: a tuple of length three if `py_version_info` is non-None.
  80. Otherwise, return `py_version_info` unchanged (i.e. None).
  81. """
  82. if len(py_version_info) < 3:
  83. py_version_info += (3 - len(py_version_info)) * (0,)
  84. elif len(py_version_info) > 3:
  85. py_version_info = py_version_info[:3]
  86. return cast("VersionInfo", py_version_info)
  87. def ensure_dir(path: str) -> None:
  88. """os.path.makedirs without EEXIST."""
  89. try:
  90. os.makedirs(path)
  91. except OSError as e:
  92. # Windows can raise spurious ENOTEMPTY errors. See #6426.
  93. if e.errno != errno.EEXIST and e.errno != errno.ENOTEMPTY:
  94. raise
  95. def get_prog() -> str:
  96. try:
  97. prog = os.path.basename(sys.argv[0])
  98. if prog in ("__main__.py", "-c"):
  99. return f"{sys.executable} -m pip"
  100. else:
  101. return prog
  102. except (AttributeError, TypeError, IndexError):
  103. pass
  104. return "pip"
  105. # Retry every half second for up to 3 seconds
  106. # Tenacity raises RetryError by default, explicitly raise the original exception
  107. @retry(reraise=True, stop=stop_after_delay(3), wait=wait_fixed(0.5))
  108. def rmtree(
  109. dir: str,
  110. ignore_errors: bool = False,
  111. onexc: Optional[OnExc] = None,
  112. ) -> None:
  113. if ignore_errors:
  114. onexc = _onerror_ignore
  115. if onexc is None:
  116. onexc = _onerror_reraise
  117. handler: OnErr = partial(
  118. # `[func, path, Union[ExcInfo, BaseException]] -> Any` is equivalent to
  119. # `Union[([func, path, ExcInfo] -> Any), ([func, path, BaseException] -> Any)]`.
  120. cast(Union[OnExc, OnErr], rmtree_errorhandler),
  121. onexc=onexc,
  122. )
  123. if sys.version_info >= (3, 12):
  124. # See https://docs.python.org/3.12/whatsnew/3.12.html#shutil.
  125. shutil.rmtree(dir, onexc=handler) # type: ignore
  126. else:
  127. shutil.rmtree(dir, onerror=handler) # type: ignore
  128. def _onerror_ignore(*_args: Any) -> None:
  129. pass
  130. def _onerror_reraise(*_args: Any) -> None:
  131. raise
  132. def rmtree_errorhandler(
  133. func: FunctionType,
  134. path: Path,
  135. exc_info: Union[ExcInfo, BaseException],
  136. *,
  137. onexc: OnExc = _onerror_reraise,
  138. ) -> None:
  139. """
  140. `rmtree` error handler to 'force' a file remove (i.e. like `rm -f`).
  141. * If a file is readonly then it's write flag is set and operation is
  142. retried.
  143. * `onerror` is the original callback from `rmtree(... onerror=onerror)`
  144. that is chained at the end if the "rm -f" still fails.
  145. """
  146. try:
  147. st_mode = os.stat(path).st_mode
  148. except OSError:
  149. # it's equivalent to os.path.exists
  150. return
  151. if not st_mode & stat.S_IWRITE:
  152. # convert to read/write
  153. try:
  154. os.chmod(path, st_mode | stat.S_IWRITE)
  155. except OSError:
  156. pass
  157. else:
  158. # use the original function to repeat the operation
  159. try:
  160. func(path)
  161. return
  162. except OSError:
  163. pass
  164. if not isinstance(exc_info, BaseException):
  165. _, exc_info, _ = exc_info
  166. onexc(func, path, exc_info)
  167. def display_path(path: str) -> str:
  168. """Gives the display value for a given path, making it relative to cwd
  169. if possible."""
  170. path = os.path.normcase(os.path.abspath(path))
  171. if path.startswith(os.getcwd() + os.path.sep):
  172. path = "." + path[len(os.getcwd()) :]
  173. return path
  174. def backup_dir(dir: str, ext: str = ".bak") -> str:
  175. """Figure out the name of a directory to back up the given dir to
  176. (adding .bak, .bak2, etc)"""
  177. n = 1
  178. extension = ext
  179. while os.path.exists(dir + extension):
  180. n += 1
  181. extension = ext + str(n)
  182. return dir + extension
  183. def ask_path_exists(message: str, options: Iterable[str]) -> str:
  184. for action in os.environ.get("PIP_EXISTS_ACTION", "").split():
  185. if action in options:
  186. return action
  187. return ask(message, options)
  188. def _check_no_input(message: str) -> None:
  189. """Raise an error if no input is allowed."""
  190. if os.environ.get("PIP_NO_INPUT"):
  191. raise Exception(
  192. f"No input was expected ($PIP_NO_INPUT set); question: {message}"
  193. )
  194. def ask(message: str, options: Iterable[str]) -> str:
  195. """Ask the message interactively, with the given possible responses"""
  196. while 1:
  197. _check_no_input(message)
  198. response = input(message)
  199. response = response.strip().lower()
  200. if response not in options:
  201. print(
  202. "Your response ({!r}) was not one of the expected responses: "
  203. "{}".format(response, ", ".join(options))
  204. )
  205. else:
  206. return response
  207. def ask_input(message: str) -> str:
  208. """Ask for input interactively."""
  209. _check_no_input(message)
  210. return input(message)
  211. def ask_password(message: str) -> str:
  212. """Ask for a password interactively."""
  213. _check_no_input(message)
  214. return getpass.getpass(message)
  215. def strtobool(val: str) -> int:
  216. """Convert a string representation of truth to true (1) or false (0).
  217. True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
  218. are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
  219. 'val' is anything else.
  220. """
  221. val = val.lower()
  222. if val in ("y", "yes", "t", "true", "on", "1"):
  223. return 1
  224. elif val in ("n", "no", "f", "false", "off", "0"):
  225. return 0
  226. else:
  227. raise ValueError(f"invalid truth value {val!r}")
  228. def format_size(bytes: float) -> str:
  229. if bytes > 1000 * 1000:
  230. return f"{bytes / 1000.0 / 1000:.1f} MB"
  231. elif bytes > 10 * 1000:
  232. return f"{int(bytes / 1000)} kB"
  233. elif bytes > 1000:
  234. return f"{bytes / 1000.0:.1f} kB"
  235. else:
  236. return f"{int(bytes)} bytes"
  237. def tabulate(rows: Iterable[Iterable[Any]]) -> Tuple[List[str], List[int]]:
  238. """Return a list of formatted rows and a list of column sizes.
  239. For example::
  240. >>> tabulate([['foobar', 2000], [0xdeadbeef]])
  241. (['foobar 2000', '3735928559'], [10, 4])
  242. """
  243. rows = [tuple(map(str, row)) for row in rows]
  244. sizes = [max(map(len, col)) for col in zip_longest(*rows, fillvalue="")]
  245. table = [" ".join(map(str.ljust, row, sizes)).rstrip() for row in rows]
  246. return table, sizes
  247. def is_installable_dir(path: str) -> bool:
  248. """Is path is a directory containing pyproject.toml or setup.py?
  249. If pyproject.toml exists, this is a PEP 517 project. Otherwise we look for
  250. a legacy setuptools layout by identifying setup.py. We don't check for the
  251. setup.cfg because using it without setup.py is only available for PEP 517
  252. projects, which are already covered by the pyproject.toml check.
  253. """
  254. if not os.path.isdir(path):
  255. return False
  256. if os.path.isfile(os.path.join(path, "pyproject.toml")):
  257. return True
  258. if os.path.isfile(os.path.join(path, "setup.py")):
  259. return True
  260. return False
  261. def read_chunks(
  262. file: BinaryIO, size: int = io.DEFAULT_BUFFER_SIZE
  263. ) -> Generator[bytes, None, None]:
  264. """Yield pieces of data from a file-like object until EOF."""
  265. while True:
  266. chunk = file.read(size)
  267. if not chunk:
  268. break
  269. yield chunk
  270. def normalize_path(path: str, resolve_symlinks: bool = True) -> str:
  271. """
  272. Convert a path to its canonical, case-normalized, absolute version.
  273. """
  274. path = os.path.expanduser(path)
  275. if resolve_symlinks:
  276. path = os.path.realpath(path)
  277. else:
  278. path = os.path.abspath(path)
  279. return os.path.normcase(path)
  280. def splitext(path: str) -> Tuple[str, str]:
  281. """Like os.path.splitext, but take off .tar too"""
  282. base, ext = posixpath.splitext(path)
  283. if base.lower().endswith(".tar"):
  284. ext = base[-4:] + ext
  285. base = base[:-4]
  286. return base, ext
  287. def renames(old: str, new: str) -> None:
  288. """Like os.renames(), but handles renaming across devices."""
  289. # Implementation borrowed from os.renames().
  290. head, tail = os.path.split(new)
  291. if head and tail and not os.path.exists(head):
  292. os.makedirs(head)
  293. shutil.move(old, new)
  294. head, tail = os.path.split(old)
  295. if head and tail:
  296. try:
  297. os.removedirs(head)
  298. except OSError:
  299. pass
  300. def is_local(path: str) -> bool:
  301. """
  302. Return True if path is within sys.prefix, if we're running in a virtualenv.
  303. If we're not in a virtualenv, all paths are considered "local."
  304. Caution: this function assumes the head of path has been normalized
  305. with normalize_path.
  306. """
  307. if not running_under_virtualenv():
  308. return True
  309. return path.startswith(normalize_path(sys.prefix))
  310. def write_output(msg: Any, *args: Any) -> None:
  311. logger.info(msg, *args)
  312. class StreamWrapper(StringIO):
  313. orig_stream: TextIO
  314. @classmethod
  315. def from_stream(cls, orig_stream: TextIO) -> "StreamWrapper":
  316. ret = cls()
  317. ret.orig_stream = orig_stream
  318. return ret
  319. # compileall.compile_dir() needs stdout.encoding to print to stdout
  320. # type ignore is because TextIOBase.encoding is writeable
  321. @property
  322. def encoding(self) -> str: # type: ignore
  323. return self.orig_stream.encoding
  324. @contextlib.contextmanager
  325. def captured_output(stream_name: str) -> Generator[StreamWrapper, None, None]:
  326. """Return a context manager used by captured_stdout/stdin/stderr
  327. that temporarily replaces the sys stream *stream_name* with a StringIO.
  328. Taken from Lib/support/__init__.py in the CPython repo.
  329. """
  330. orig_stdout = getattr(sys, stream_name)
  331. setattr(sys, stream_name, StreamWrapper.from_stream(orig_stdout))
  332. try:
  333. yield getattr(sys, stream_name)
  334. finally:
  335. setattr(sys, stream_name, orig_stdout)
  336. def captured_stdout() -> ContextManager[StreamWrapper]:
  337. """Capture the output of sys.stdout:
  338. with captured_stdout() as stdout:
  339. print('hello')
  340. self.assertEqual(stdout.getvalue(), 'hello\n')
  341. Taken from Lib/support/__init__.py in the CPython repo.
  342. """
  343. return captured_output("stdout")
  344. def captured_stderr() -> ContextManager[StreamWrapper]:
  345. """
  346. See captured_stdout().
  347. """
  348. return captured_output("stderr")
  349. # Simulates an enum
  350. def enum(*sequential: Any, **named: Any) -> Type[Any]:
  351. enums = dict(zip(sequential, range(len(sequential))), **named)
  352. reverse = {value: key for key, value in enums.items()}
  353. enums["reverse_mapping"] = reverse
  354. return type("Enum", (), enums)
  355. def build_netloc(host: str, port: Optional[int]) -> str:
  356. """
  357. Build a netloc from a host-port pair
  358. """
  359. if port is None:
  360. return host
  361. if ":" in host:
  362. # Only wrap host with square brackets when it is IPv6
  363. host = f"[{host}]"
  364. return f"{host}:{port}"
  365. def build_url_from_netloc(netloc: str, scheme: str = "https") -> str:
  366. """
  367. Build a full URL from a netloc.
  368. """
  369. if netloc.count(":") >= 2 and "@" not in netloc and "[" not in netloc:
  370. # It must be a bare IPv6 address, so wrap it with brackets.
  371. netloc = f"[{netloc}]"
  372. return f"{scheme}://{netloc}"
  373. def parse_netloc(netloc: str) -> Tuple[Optional[str], Optional[int]]:
  374. """
  375. Return the host-port pair from a netloc.
  376. """
  377. url = build_url_from_netloc(netloc)
  378. parsed = urllib.parse.urlparse(url)
  379. return parsed.hostname, parsed.port
  380. def split_auth_from_netloc(netloc: str) -> NetlocTuple:
  381. """
  382. Parse out and remove the auth information from a netloc.
  383. Returns: (netloc, (username, password)).
  384. """
  385. if "@" not in netloc:
  386. return netloc, (None, None)
  387. # Split from the right because that's how urllib.parse.urlsplit()
  388. # behaves if more than one @ is present (which can be checked using
  389. # the password attribute of urlsplit()'s return value).
  390. auth, netloc = netloc.rsplit("@", 1)
  391. pw: Optional[str] = None
  392. if ":" in auth:
  393. # Split from the left because that's how urllib.parse.urlsplit()
  394. # behaves if more than one : is present (which again can be checked
  395. # using the password attribute of the return value)
  396. user, pw = auth.split(":", 1)
  397. else:
  398. user, pw = auth, None
  399. user = urllib.parse.unquote(user)
  400. if pw is not None:
  401. pw = urllib.parse.unquote(pw)
  402. return netloc, (user, pw)
  403. def redact_netloc(netloc: str) -> str:
  404. """
  405. Replace the sensitive data in a netloc with "****", if it exists.
  406. For example:
  407. - "user:pass@example.com" returns "user:****@example.com"
  408. - "accesstoken@example.com" returns "****@example.com"
  409. """
  410. netloc, (user, password) = split_auth_from_netloc(netloc)
  411. if user is None:
  412. return netloc
  413. if password is None:
  414. user = "****"
  415. password = ""
  416. else:
  417. user = urllib.parse.quote(user)
  418. password = ":****"
  419. return f"{user}{password}@{netloc}"
  420. def _transform_url(
  421. url: str, transform_netloc: Callable[[str], Tuple[Any, ...]]
  422. ) -> Tuple[str, NetlocTuple]:
  423. """Transform and replace netloc in a url.
  424. transform_netloc is a function taking the netloc and returning a
  425. tuple. The first element of this tuple is the new netloc. The
  426. entire tuple is returned.
  427. Returns a tuple containing the transformed url as item 0 and the
  428. original tuple returned by transform_netloc as item 1.
  429. """
  430. purl = urllib.parse.urlsplit(url)
  431. netloc_tuple = transform_netloc(purl.netloc)
  432. # stripped url
  433. url_pieces = (purl.scheme, netloc_tuple[0], purl.path, purl.query, purl.fragment)
  434. surl = urllib.parse.urlunsplit(url_pieces)
  435. return surl, cast("NetlocTuple", netloc_tuple)
  436. def _get_netloc(netloc: str) -> NetlocTuple:
  437. return split_auth_from_netloc(netloc)
  438. def _redact_netloc(netloc: str) -> Tuple[str]:
  439. return (redact_netloc(netloc),)
  440. def split_auth_netloc_from_url(
  441. url: str,
  442. ) -> Tuple[str, str, Tuple[Optional[str], Optional[str]]]:
  443. """
  444. Parse a url into separate netloc, auth, and url with no auth.
  445. Returns: (url_without_auth, netloc, (username, password))
  446. """
  447. url_without_auth, (netloc, auth) = _transform_url(url, _get_netloc)
  448. return url_without_auth, netloc, auth
  449. def remove_auth_from_url(url: str) -> str:
  450. """Return a copy of url with 'username:password@' removed."""
  451. # username/pass params are passed to subversion through flags
  452. # and are not recognized in the url.
  453. return _transform_url(url, _get_netloc)[0]
  454. def redact_auth_from_url(url: str) -> str:
  455. """Replace the password in a given url with ****."""
  456. return _transform_url(url, _redact_netloc)[0]
  457. def redact_auth_from_requirement(req: Requirement) -> str:
  458. """Replace the password in a given requirement url with ****."""
  459. if not req.url:
  460. return str(req)
  461. return str(req).replace(req.url, redact_auth_from_url(req.url))
  462. class HiddenText:
  463. def __init__(self, secret: str, redacted: str) -> None:
  464. self.secret = secret
  465. self.redacted = redacted
  466. def __repr__(self) -> str:
  467. return f"<HiddenText {str(self)!r}>"
  468. def __str__(self) -> str:
  469. return self.redacted
  470. # This is useful for testing.
  471. def __eq__(self, other: Any) -> bool:
  472. if type(self) != type(other):
  473. return False
  474. # The string being used for redaction doesn't also have to match,
  475. # just the raw, original string.
  476. return self.secret == other.secret
  477. def hide_value(value: str) -> HiddenText:
  478. return HiddenText(value, redacted="****")
  479. def hide_url(url: str) -> HiddenText:
  480. redacted = redact_auth_from_url(url)
  481. return HiddenText(url, redacted=redacted)
  482. def protect_pip_from_modification_on_windows(modifying_pip: bool) -> None:
  483. """Protection of pip.exe from modification on Windows
  484. On Windows, any operation modifying pip should be run as:
  485. python -m pip ...
  486. """
  487. pip_names = [
  488. "pip",
  489. f"pip{sys.version_info.major}",
  490. f"pip{sys.version_info.major}.{sys.version_info.minor}",
  491. ]
  492. # See https://github.com/pypa/pip/issues/1299 for more discussion
  493. should_show_use_python_msg = (
  494. modifying_pip and WINDOWS and os.path.basename(sys.argv[0]) in pip_names
  495. )
  496. if should_show_use_python_msg:
  497. new_command = [sys.executable, "-m", "pip"] + sys.argv[1:]
  498. raise CommandError(
  499. "To modify pip, please run the following command:\n{}".format(
  500. " ".join(new_command)
  501. )
  502. )
  503. def check_externally_managed() -> None:
  504. """Check whether the current environment is externally managed.
  505. If the ``EXTERNALLY-MANAGED`` config file is found, the current environment
  506. is considered externally managed, and an ExternallyManagedEnvironment is
  507. raised.
  508. """
  509. if running_under_virtualenv():
  510. return
  511. marker = os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED")
  512. if not os.path.isfile(marker):
  513. return
  514. raise ExternallyManagedEnvironment.from_config(marker)
  515. def is_console_interactive() -> bool:
  516. """Is this console interactive?"""
  517. return sys.stdin is not None and sys.stdin.isatty()
  518. def hash_file(path: str, blocksize: int = 1 << 20) -> Tuple[Any, int]:
  519. """Return (hash, length) for path using hashlib.sha256()"""
  520. h = hashlib.sha256()
  521. length = 0
  522. with open(path, "rb") as f:
  523. for block in read_chunks(f, size=blocksize):
  524. length += len(block)
  525. h.update(block)
  526. return h, length
  527. def pairwise(iterable: Iterable[Any]) -> Iterator[Tuple[Any, Any]]:
  528. """
  529. Return paired elements.
  530. For example:
  531. s -> (s0, s1), (s2, s3), (s4, s5), ...
  532. """
  533. iterable = iter(iterable)
  534. return zip_longest(iterable, iterable)
  535. def partition(
  536. pred: Callable[[T], bool],
  537. iterable: Iterable[T],
  538. ) -> Tuple[Iterable[T], Iterable[T]]:
  539. """
  540. Use a predicate to partition entries into false entries and true entries,
  541. like
  542. partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
  543. """
  544. t1, t2 = tee(iterable)
  545. return filterfalse(pred, t1), filter(pred, t2)
  546. class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
  547. def __init__(
  548. self,
  549. config_holder: Any,
  550. source_dir: str,
  551. build_backend: str,
  552. backend_path: Optional[str] = None,
  553. runner: Optional[Callable[..., None]] = None,
  554. python_executable: Optional[str] = None,
  555. ):
  556. super().__init__(
  557. source_dir, build_backend, backend_path, runner, python_executable
  558. )
  559. self.config_holder = config_holder
  560. def build_wheel(
  561. self,
  562. wheel_directory: str,
  563. config_settings: Optional[Dict[str, Union[str, List[str]]]] = None,
  564. metadata_directory: Optional[str] = None,
  565. ) -> str:
  566. cs = self.config_holder.config_settings
  567. return super().build_wheel(
  568. wheel_directory, config_settings=cs, metadata_directory=metadata_directory
  569. )
  570. def build_sdist(
  571. self,
  572. sdist_directory: str,
  573. config_settings: Optional[Dict[str, Union[str, List[str]]]] = None,
  574. ) -> str:
  575. cs = self.config_holder.config_settings
  576. return super().build_sdist(sdist_directory, config_settings=cs)
  577. def build_editable(
  578. self,
  579. wheel_directory: str,
  580. config_settings: Optional[Dict[str, Union[str, List[str]]]] = None,
  581. metadata_directory: Optional[str] = None,
  582. ) -> str:
  583. cs = self.config_holder.config_settings
  584. return super().build_editable(
  585. wheel_directory, config_settings=cs, metadata_directory=metadata_directory
  586. )
  587. def get_requires_for_build_wheel(
  588. self, config_settings: Optional[Dict[str, Union[str, List[str]]]] = None
  589. ) -> List[str]:
  590. cs = self.config_holder.config_settings
  591. return super().get_requires_for_build_wheel(config_settings=cs)
  592. def get_requires_for_build_sdist(
  593. self, config_settings: Optional[Dict[str, Union[str, List[str]]]] = None
  594. ) -> List[str]:
  595. cs = self.config_holder.config_settings
  596. return super().get_requires_for_build_sdist(config_settings=cs)
  597. def get_requires_for_build_editable(
  598. self, config_settings: Optional[Dict[str, Union[str, List[str]]]] = None
  599. ) -> List[str]:
  600. cs = self.config_holder.config_settings
  601. return super().get_requires_for_build_editable(config_settings=cs)
  602. def prepare_metadata_for_build_wheel(
  603. self,
  604. metadata_directory: str,
  605. config_settings: Optional[Dict[str, Union[str, List[str]]]] = None,
  606. _allow_fallback: bool = True,
  607. ) -> str:
  608. cs = self.config_holder.config_settings
  609. return super().prepare_metadata_for_build_wheel(
  610. metadata_directory=metadata_directory,
  611. config_settings=cs,
  612. _allow_fallback=_allow_fallback,
  613. )
  614. def prepare_metadata_for_build_editable(
  615. self,
  616. metadata_directory: str,
  617. config_settings: Optional[Dict[str, Union[str, List[str]]]] = None,
  618. _allow_fallback: bool = True,
  619. ) -> str:
  620. cs = self.config_holder.config_settings
  621. return super().prepare_metadata_for_build_editable(
  622. metadata_directory=metadata_directory,
  623. config_settings=cs,
  624. _allow_fallback=_allow_fallback,
  625. )