base.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. from __future__ import annotations
  2. import csv
  3. import email.message
  4. import functools
  5. import json
  6. import logging
  7. import pathlib
  8. import re
  9. import zipfile
  10. from collections.abc import Collection, Container, Iterable, Iterator
  11. from typing import (
  12. IO,
  13. Any,
  14. NamedTuple,
  15. Protocol,
  16. Union,
  17. )
  18. from pip._vendor.packaging.requirements import Requirement
  19. from pip._vendor.packaging.specifiers import InvalidSpecifier, SpecifierSet
  20. from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
  21. from pip._vendor.packaging.version import Version
  22. from pip._internal.exceptions import NoneMetadataError
  23. from pip._internal.locations import site_packages, user_site
  24. from pip._internal.models.direct_url import (
  25. DIRECT_URL_METADATA_NAME,
  26. DirectUrl,
  27. DirectUrlValidationError,
  28. )
  29. from pip._internal.utils.compat import stdlib_pkgs # TODO: Move definition here.
  30. from pip._internal.utils.egg_link import egg_link_path_from_sys_path
  31. from pip._internal.utils.misc import is_local, normalize_path
  32. from pip._internal.utils.urls import url_to_path
  33. from ._json import msg_to_json
  34. InfoPath = Union[str, pathlib.PurePath]
  35. logger = logging.getLogger(__name__)
  36. class BaseEntryPoint(Protocol):
  37. @property
  38. def name(self) -> str:
  39. raise NotImplementedError()
  40. @property
  41. def value(self) -> str:
  42. raise NotImplementedError()
  43. @property
  44. def group(self) -> str:
  45. raise NotImplementedError()
  46. def _convert_installed_files_path(
  47. entry: tuple[str, ...],
  48. info: tuple[str, ...],
  49. ) -> str:
  50. """Convert a legacy installed-files.txt path into modern RECORD path.
  51. The legacy format stores paths relative to the info directory, while the
  52. modern format stores paths relative to the package root, e.g. the
  53. site-packages directory.
  54. :param entry: Path parts of the installed-files.txt entry.
  55. :param info: Path parts of the egg-info directory relative to package root.
  56. :returns: The converted entry.
  57. For best compatibility with symlinks, this does not use ``abspath()`` or
  58. ``Path.resolve()``, but tries to work with path parts:
  59. 1. While ``entry`` starts with ``..``, remove the equal amounts of parts
  60. from ``info``; if ``info`` is empty, start appending ``..`` instead.
  61. 2. Join the two directly.
  62. """
  63. while entry and entry[0] == "..":
  64. if not info or info[-1] == "..":
  65. info += ("..",)
  66. else:
  67. info = info[:-1]
  68. entry = entry[1:]
  69. return str(pathlib.Path(*info, *entry))
  70. class RequiresEntry(NamedTuple):
  71. requirement: str
  72. extra: str
  73. marker: str
  74. class BaseDistribution(Protocol):
  75. @classmethod
  76. def from_directory(cls, directory: str) -> BaseDistribution:
  77. """Load the distribution from a metadata directory.
  78. :param directory: Path to a metadata directory, e.g. ``.dist-info``.
  79. """
  80. raise NotImplementedError()
  81. @classmethod
  82. def from_metadata_file_contents(
  83. cls,
  84. metadata_contents: bytes,
  85. filename: str,
  86. project_name: str,
  87. ) -> BaseDistribution:
  88. """Load the distribution from the contents of a METADATA file.
  89. This is used to implement PEP 658 by generating a "shallow" dist object that can
  90. be used for resolution without downloading or building the actual dist yet.
  91. :param metadata_contents: The contents of a METADATA file.
  92. :param filename: File name for the dist with this metadata.
  93. :param project_name: Name of the project this dist represents.
  94. """
  95. raise NotImplementedError()
  96. @classmethod
  97. def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:
  98. """Load the distribution from a given wheel.
  99. :param wheel: A concrete wheel definition.
  100. :param name: File name of the wheel.
  101. :raises InvalidWheel: Whenever loading of the wheel causes a
  102. :py:exc:`zipfile.BadZipFile` exception to be thrown.
  103. :raises UnsupportedWheel: If the wheel is a valid zip, but malformed
  104. internally.
  105. """
  106. raise NotImplementedError()
  107. def __repr__(self) -> str:
  108. return f"{self.raw_name} {self.raw_version} ({self.location})"
  109. def __str__(self) -> str:
  110. return f"{self.raw_name} {self.raw_version}"
  111. @property
  112. def location(self) -> str | None:
  113. """Where the distribution is loaded from.
  114. A string value is not necessarily a filesystem path, since distributions
  115. can be loaded from other sources, e.g. arbitrary zip archives. ``None``
  116. means the distribution is created in-memory.
  117. Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
  118. this is a symbolic link, we want to preserve the relative path between
  119. it and files in the distribution.
  120. """
  121. raise NotImplementedError()
  122. @property
  123. def editable_project_location(self) -> str | None:
  124. """The project location for editable distributions.
  125. This is the directory where pyproject.toml or setup.py is located.
  126. None if the distribution is not installed in editable mode.
  127. """
  128. # TODO: this property is relatively costly to compute, memoize it ?
  129. direct_url = self.direct_url
  130. if direct_url:
  131. if direct_url.is_local_editable():
  132. return url_to_path(direct_url.url)
  133. else:
  134. # Search for an .egg-link file by walking sys.path, as it was
  135. # done before by dist_is_editable().
  136. egg_link_path = egg_link_path_from_sys_path(self.raw_name)
  137. if egg_link_path:
  138. # TODO: get project location from second line of egg_link file
  139. # (https://github.com/pypa/pip/issues/10243)
  140. return self.location
  141. return None
  142. @property
  143. def installed_location(self) -> str | None:
  144. """The distribution's "installed" location.
  145. This should generally be a ``site-packages`` directory. This is
  146. usually ``dist.location``, except for legacy develop-installed packages,
  147. where ``dist.location`` is the source code location, and this is where
  148. the ``.egg-link`` file is.
  149. The returned location is normalized (in particular, with symlinks removed).
  150. """
  151. raise NotImplementedError()
  152. @property
  153. def info_location(self) -> str | None:
  154. """Location of the .[egg|dist]-info directory or file.
  155. Similarly to ``location``, a string value is not necessarily a
  156. filesystem path. ``None`` means the distribution is created in-memory.
  157. For a modern .dist-info installation on disk, this should be something
  158. like ``{location}/{raw_name}-{version}.dist-info``.
  159. Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
  160. this is a symbolic link, we want to preserve the relative path between
  161. it and other files in the distribution.
  162. """
  163. raise NotImplementedError()
  164. @property
  165. def installed_by_distutils(self) -> bool:
  166. """Whether this distribution is installed with legacy distutils format.
  167. A distribution installed with "raw" distutils not patched by setuptools
  168. uses one single file at ``info_location`` to store metadata. We need to
  169. treat this specially on uninstallation.
  170. """
  171. info_location = self.info_location
  172. if not info_location:
  173. return False
  174. return pathlib.Path(info_location).is_file()
  175. @property
  176. def installed_as_egg(self) -> bool:
  177. """Whether this distribution is installed as an egg.
  178. This usually indicates the distribution was installed by (older versions
  179. of) easy_install.
  180. """
  181. location = self.location
  182. if not location:
  183. return False
  184. # XXX if the distribution is a zipped egg, location has a trailing /
  185. # so we resort to pathlib.Path to check the suffix in a reliable way.
  186. return pathlib.Path(location).suffix == ".egg"
  187. @property
  188. def installed_with_setuptools_egg_info(self) -> bool:
  189. """Whether this distribution is installed with the ``.egg-info`` format.
  190. This usually indicates the distribution was installed with setuptools
  191. with an old pip version or with ``single-version-externally-managed``.
  192. Note that this ensure the metadata store is a directory. distutils can
  193. also installs an ``.egg-info``, but as a file, not a directory. This
  194. property is *False* for that case. Also see ``installed_by_distutils``.
  195. """
  196. info_location = self.info_location
  197. if not info_location:
  198. return False
  199. if not info_location.endswith(".egg-info"):
  200. return False
  201. return pathlib.Path(info_location).is_dir()
  202. @property
  203. def installed_with_dist_info(self) -> bool:
  204. """Whether this distribution is installed with the "modern format".
  205. This indicates a "modern" installation, e.g. storing metadata in the
  206. ``.dist-info`` directory. This applies to installations made by
  207. setuptools (but through pip, not directly), or anything using the
  208. standardized build backend interface (PEP 517).
  209. """
  210. info_location = self.info_location
  211. if not info_location:
  212. return False
  213. if not info_location.endswith(".dist-info"):
  214. return False
  215. return pathlib.Path(info_location).is_dir()
  216. @property
  217. def canonical_name(self) -> NormalizedName:
  218. raise NotImplementedError()
  219. @property
  220. def version(self) -> Version:
  221. raise NotImplementedError()
  222. @property
  223. def raw_version(self) -> str:
  224. raise NotImplementedError()
  225. @property
  226. def setuptools_filename(self) -> str:
  227. """Convert a project name to its setuptools-compatible filename.
  228. This is a copy of ``pkg_resources.to_filename()`` for compatibility.
  229. """
  230. return self.raw_name.replace("-", "_")
  231. @property
  232. def direct_url(self) -> DirectUrl | None:
  233. """Obtain a DirectUrl from this distribution.
  234. Returns None if the distribution has no `direct_url.json` metadata,
  235. or if `direct_url.json` is invalid.
  236. """
  237. try:
  238. content = self.read_text(DIRECT_URL_METADATA_NAME)
  239. except FileNotFoundError:
  240. return None
  241. try:
  242. return DirectUrl.from_json(content)
  243. except (
  244. UnicodeDecodeError,
  245. json.JSONDecodeError,
  246. DirectUrlValidationError,
  247. ) as e:
  248. logger.warning(
  249. "Error parsing %s for %s: %s",
  250. DIRECT_URL_METADATA_NAME,
  251. self.canonical_name,
  252. e,
  253. )
  254. return None
  255. @property
  256. def installer(self) -> str:
  257. try:
  258. installer_text = self.read_text("INSTALLER")
  259. except (OSError, ValueError, NoneMetadataError):
  260. return "" # Fail silently if the installer file cannot be read.
  261. for line in installer_text.splitlines():
  262. cleaned_line = line.strip()
  263. if cleaned_line:
  264. return cleaned_line
  265. return ""
  266. @property
  267. def requested(self) -> bool:
  268. return self.is_file("REQUESTED")
  269. @property
  270. def editable(self) -> bool:
  271. return bool(self.editable_project_location)
  272. @property
  273. def local(self) -> bool:
  274. """If distribution is installed in the current virtual environment.
  275. Always True if we're not in a virtualenv.
  276. """
  277. if self.installed_location is None:
  278. return False
  279. return is_local(self.installed_location)
  280. @property
  281. def in_usersite(self) -> bool:
  282. if self.installed_location is None or user_site is None:
  283. return False
  284. return self.installed_location.startswith(normalize_path(user_site))
  285. @property
  286. def in_site_packages(self) -> bool:
  287. if self.installed_location is None or site_packages is None:
  288. return False
  289. return self.installed_location.startswith(normalize_path(site_packages))
  290. def is_file(self, path: InfoPath) -> bool:
  291. """Check whether an entry in the info directory is a file."""
  292. raise NotImplementedError()
  293. def iter_distutils_script_names(self) -> Iterator[str]:
  294. """Find distutils 'scripts' entries metadata.
  295. If 'scripts' is supplied in ``setup.py``, distutils records those in the
  296. installed distribution's ``scripts`` directory, a file for each script.
  297. """
  298. raise NotImplementedError()
  299. def read_text(self, path: InfoPath) -> str:
  300. """Read a file in the info directory.
  301. :raise FileNotFoundError: If ``path`` does not exist in the directory.
  302. :raise NoneMetadataError: If ``path`` exists in the info directory, but
  303. cannot be read.
  304. """
  305. raise NotImplementedError()
  306. def iter_entry_points(self) -> Iterable[BaseEntryPoint]:
  307. raise NotImplementedError()
  308. def _metadata_impl(self) -> email.message.Message:
  309. raise NotImplementedError()
  310. @functools.cached_property
  311. def metadata(self) -> email.message.Message:
  312. """Metadata of distribution parsed from e.g. METADATA or PKG-INFO.
  313. This should return an empty message if the metadata file is unavailable.
  314. :raises NoneMetadataError: If the metadata file is available, but does
  315. not contain valid metadata.
  316. """
  317. metadata = self._metadata_impl()
  318. self._add_egg_info_requires(metadata)
  319. return metadata
  320. @property
  321. def metadata_dict(self) -> dict[str, Any]:
  322. """PEP 566 compliant JSON-serializable representation of METADATA or PKG-INFO.
  323. This should return an empty dict if the metadata file is unavailable.
  324. :raises NoneMetadataError: If the metadata file is available, but does
  325. not contain valid metadata.
  326. """
  327. return msg_to_json(self.metadata)
  328. @property
  329. def metadata_version(self) -> str | None:
  330. """Value of "Metadata-Version:" in distribution metadata, if available."""
  331. return self.metadata.get("Metadata-Version")
  332. @property
  333. def raw_name(self) -> str:
  334. """Value of "Name:" in distribution metadata."""
  335. # The metadata should NEVER be missing the Name: key, but if it somehow
  336. # does, fall back to the known canonical name.
  337. return self.metadata.get("Name", self.canonical_name)
  338. @property
  339. def requires_python(self) -> SpecifierSet:
  340. """Value of "Requires-Python:" in distribution metadata.
  341. If the key does not exist or contains an invalid value, an empty
  342. SpecifierSet should be returned.
  343. """
  344. value = self.metadata.get("Requires-Python")
  345. if value is None:
  346. return SpecifierSet()
  347. try:
  348. # Convert to str to satisfy the type checker; this can be a Header object.
  349. spec = SpecifierSet(str(value))
  350. except InvalidSpecifier as e:
  351. message = "Package %r has an invalid Requires-Python: %s"
  352. logger.warning(message, self.raw_name, e)
  353. return SpecifierSet()
  354. return spec
  355. def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requirement]:
  356. """Dependencies of this distribution.
  357. For modern .dist-info distributions, this is the collection of
  358. "Requires-Dist:" entries in distribution metadata.
  359. """
  360. raise NotImplementedError()
  361. def iter_raw_dependencies(self) -> Iterable[str]:
  362. """Raw Requires-Dist metadata."""
  363. return self.metadata.get_all("Requires-Dist", [])
  364. def iter_provided_extras(self) -> Iterable[NormalizedName]:
  365. """Extras provided by this distribution.
  366. For modern .dist-info distributions, this is the collection of
  367. "Provides-Extra:" entries in distribution metadata.
  368. The return value of this function is expected to be normalised names,
  369. per PEP 685, with the returned value being handled appropriately by
  370. `iter_dependencies`.
  371. """
  372. raise NotImplementedError()
  373. def _iter_declared_entries_from_record(self) -> Iterator[str] | None:
  374. try:
  375. text = self.read_text("RECORD")
  376. except FileNotFoundError:
  377. return None
  378. # This extra Path-str cast normalizes entries.
  379. return (str(pathlib.Path(row[0])) for row in csv.reader(text.splitlines()))
  380. def _iter_declared_entries_from_legacy(self) -> Iterator[str] | None:
  381. try:
  382. text = self.read_text("installed-files.txt")
  383. except FileNotFoundError:
  384. return None
  385. paths = (p for p in text.splitlines(keepends=False) if p)
  386. root = self.location
  387. info = self.info_location
  388. if root is None or info is None:
  389. return paths
  390. try:
  391. info_rel = pathlib.Path(info).relative_to(root)
  392. except ValueError: # info is not relative to root.
  393. return paths
  394. if not info_rel.parts: # info *is* root.
  395. return paths
  396. return (
  397. _convert_installed_files_path(pathlib.Path(p).parts, info_rel.parts)
  398. for p in paths
  399. )
  400. def iter_declared_entries(self) -> Iterator[str] | None:
  401. """Iterate through file entries declared in this distribution.
  402. For modern .dist-info distributions, this is the files listed in the
  403. ``RECORD`` metadata file. For legacy setuptools distributions, this
  404. comes from ``installed-files.txt``, with entries normalized to be
  405. compatible with the format used by ``RECORD``.
  406. :return: An iterator for listed entries, or None if the distribution
  407. contains neither ``RECORD`` nor ``installed-files.txt``.
  408. """
  409. return (
  410. self._iter_declared_entries_from_record()
  411. or self._iter_declared_entries_from_legacy()
  412. )
  413. def _iter_requires_txt_entries(self) -> Iterator[RequiresEntry]:
  414. """Parse a ``requires.txt`` in an egg-info directory.
  415. This is an INI-ish format where an egg-info stores dependencies. A
  416. section name describes extra other environment markers, while each entry
  417. is an arbitrary string (not a key-value pair) representing a dependency
  418. as a requirement string (no markers).
  419. There is a construct in ``importlib.metadata`` called ``Sectioned`` that
  420. does mostly the same, but the format is currently considered private.
  421. """
  422. try:
  423. content = self.read_text("requires.txt")
  424. except FileNotFoundError:
  425. return
  426. extra = marker = "" # Section-less entries don't have markers.
  427. for line in content.splitlines():
  428. line = line.strip()
  429. if not line or line.startswith("#"): # Comment; ignored.
  430. continue
  431. if line.startswith("[") and line.endswith("]"): # A section header.
  432. extra, _, marker = line.strip("[]").partition(":")
  433. continue
  434. yield RequiresEntry(requirement=line, extra=extra, marker=marker)
  435. def _iter_egg_info_extras(self) -> Iterable[str]:
  436. """Get extras from the egg-info directory."""
  437. known_extras = {""}
  438. for entry in self._iter_requires_txt_entries():
  439. extra = canonicalize_name(entry.extra)
  440. if extra in known_extras:
  441. continue
  442. known_extras.add(extra)
  443. yield extra
  444. def _iter_egg_info_dependencies(self) -> Iterable[str]:
  445. """Get distribution dependencies from the egg-info directory.
  446. To ease parsing, this converts a legacy dependency entry into a PEP 508
  447. requirement string. Like ``_iter_requires_txt_entries()``, there is code
  448. in ``importlib.metadata`` that does mostly the same, but not do exactly
  449. what we need.
  450. Namely, ``importlib.metadata`` does not normalize the extra name before
  451. putting it into the requirement string, which causes marker comparison
  452. to fail because the dist-info format do normalize. This is consistent in
  453. all currently available PEP 517 backends, although not standardized.
  454. """
  455. for entry in self._iter_requires_txt_entries():
  456. extra = canonicalize_name(entry.extra)
  457. if extra and entry.marker:
  458. marker = f'({entry.marker}) and extra == "{extra}"'
  459. elif extra:
  460. marker = f'extra == "{extra}"'
  461. elif entry.marker:
  462. marker = entry.marker
  463. else:
  464. marker = ""
  465. if marker:
  466. yield f"{entry.requirement} ; {marker}"
  467. else:
  468. yield entry.requirement
  469. def _add_egg_info_requires(self, metadata: email.message.Message) -> None:
  470. """Add egg-info requires.txt information to the metadata."""
  471. if not metadata.get_all("Requires-Dist"):
  472. for dep in self._iter_egg_info_dependencies():
  473. metadata["Requires-Dist"] = dep
  474. if not metadata.get_all("Provides-Extra"):
  475. for extra in self._iter_egg_info_extras():
  476. metadata["Provides-Extra"] = extra
  477. class BaseEnvironment:
  478. """An environment containing distributions to introspect."""
  479. @classmethod
  480. def default(cls) -> BaseEnvironment:
  481. raise NotImplementedError()
  482. @classmethod
  483. def from_paths(cls, paths: list[str] | None) -> BaseEnvironment:
  484. raise NotImplementedError()
  485. def get_distribution(self, name: str) -> BaseDistribution | None:
  486. """Given a requirement name, return the installed distributions.
  487. The name may not be normalized. The implementation must canonicalize
  488. it for lookup.
  489. """
  490. raise NotImplementedError()
  491. def _iter_distributions(self) -> Iterator[BaseDistribution]:
  492. """Iterate through installed distributions.
  493. This function should be implemented by subclass, but never called
  494. directly. Use the public ``iter_distribution()`` instead, which
  495. implements additional logic to make sure the distributions are valid.
  496. """
  497. raise NotImplementedError()
  498. def iter_all_distributions(self) -> Iterator[BaseDistribution]:
  499. """Iterate through all installed distributions without any filtering."""
  500. for dist in self._iter_distributions():
  501. # Make sure the distribution actually comes from a valid Python
  502. # packaging distribution. Pip's AdjacentTempDirectory leaves folders
  503. # e.g. ``~atplotlib.dist-info`` if cleanup was interrupted. The
  504. # valid project name pattern is taken from PEP 508.
  505. project_name_valid = re.match(
  506. r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",
  507. dist.canonical_name,
  508. flags=re.IGNORECASE,
  509. )
  510. if not project_name_valid:
  511. logger.warning(
  512. "Ignoring invalid distribution %s (%s)",
  513. dist.canonical_name,
  514. dist.location,
  515. )
  516. continue
  517. yield dist
  518. def iter_installed_distributions(
  519. self,
  520. local_only: bool = True,
  521. skip: Container[str] = stdlib_pkgs,
  522. include_editables: bool = True,
  523. editables_only: bool = False,
  524. user_only: bool = False,
  525. ) -> Iterator[BaseDistribution]:
  526. """Return a list of installed distributions.
  527. This is based on ``iter_all_distributions()`` with additional filtering
  528. options. Note that ``iter_installed_distributions()`` without arguments
  529. is *not* equal to ``iter_all_distributions()``, since some of the
  530. configurations exclude packages by default.
  531. :param local_only: If True (default), only return installations
  532. local to the current virtualenv, if in a virtualenv.
  533. :param skip: An iterable of canonicalized project names to ignore;
  534. defaults to ``stdlib_pkgs``.
  535. :param include_editables: If False, don't report editables.
  536. :param editables_only: If True, only report editables.
  537. :param user_only: If True, only report installations in the user
  538. site directory.
  539. """
  540. it = self.iter_all_distributions()
  541. if local_only:
  542. it = (d for d in it if d.local)
  543. if not include_editables:
  544. it = (d for d in it if not d.editable)
  545. if editables_only:
  546. it = (d for d in it if d.editable)
  547. if user_only:
  548. it = (d for d in it if d.in_usersite)
  549. return (d for d in it if d.canonical_name not in skip)
  550. class Wheel(Protocol):
  551. location: str
  552. def as_zipfile(self) -> zipfile.ZipFile:
  553. raise NotImplementedError()
  554. class FilesystemWheel(Wheel):
  555. def __init__(self, location: str) -> None:
  556. self.location = location
  557. def as_zipfile(self) -> zipfile.ZipFile:
  558. return zipfile.ZipFile(self.location, allowZip64=True)
  559. class MemoryWheel(Wheel):
  560. def __init__(self, location: str, stream: IO[bytes]) -> None:
  561. self.location = location
  562. self.stream = stream
  563. def as_zipfile(self) -> zipfile.ZipFile:
  564. return zipfile.ZipFile(self.stream, allowZip64=True)