misc.py 22 KB

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