Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hhhrrrttt222111
GitHub Repository: hhhrrrttt222111/Dorkify
Path: blob/master/venv/Lib/site-packages/pip/_internal/distributions/wheel.py
811 views
1
from zipfile import ZipFile
2
3
from pip._internal.distributions.base import AbstractDistribution
4
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
5
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
6
7
if MYPY_CHECK_RUNNING:
8
from pip._vendor.pkg_resources import Distribution
9
from pip._internal.index.package_finder import PackageFinder
10
11
12
class WheelDistribution(AbstractDistribution):
13
"""Represents a wheel distribution.
14
15
This does not need any preparation as wheels can be directly unpacked.
16
"""
17
18
def get_pkg_resources_distribution(self):
19
# type: () -> Distribution
20
"""Loads the metadata from the wheel file into memory and returns a
21
Distribution that uses it, not relying on the wheel file or
22
requirement.
23
"""
24
# Set as part of preparation during download.
25
assert self.req.local_file_path
26
# Wheels are never unnamed.
27
assert self.req.name
28
29
with ZipFile(self.req.local_file_path, allowZip64=True) as z:
30
return pkg_resources_distribution_for_wheel(
31
z, self.req.name, self.req.local_file_path
32
)
33
34
def prepare_distribution_metadata(self, finder, build_isolation):
35
# type: (PackageFinder, bool) -> None
36
pass
37
38