misc.py 22 KB

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