Caution
This API is not finalised, and may change in a patch version.
installer.sources
¶
Source of information about a wheel file.
- class installer.sources.WheelSource(distribution, version)¶
Represents an installable wheel.
This is an abstract class, whose methods have to be implemented by subclasses.
- Parameters
distribution (Text) –
version (Text) –
- Return type
- property dist_info_dir¶
Name of the dist-info directory.
- property data_dir¶
Name of the data directory.
- property dist_info_filenames¶
Get names of all files in the dist-info directory.
Sample usage/behaviour:
>>> wheel_source.dist_info_filenames ['METADATA', 'WHEEL']
- read_dist_info(filename)¶
Get contents, from
filename
in the dist-info directory.Sample usage/behaviour:
>>> wheel_source.read_dist_info("METADATA") ...
- Parameters
filename (FSPath) – name of the file
- Return type
Text
- get_contents()¶
Sequential access to all contents of the wheel (including dist-info files).
This method should return an iterable. Each value from the iterable must be a tuple containing 2 elements:
record: 3-value tuple, to pass to
RecordEntry.from_elements
.stream: An
io.BufferedReader
object, providing the contents of the file at the location provided by the first element (path).
All paths must be relative to the root of the wheel.
Sample usage/behaviour:
>>> iterable = wheel_source.get_contents() >>> next(iterable) (('pkg/__init__.py', '', '0'), <...>)
This method may be called multiple times. Each iterable returned must provide the same content upon reading from a specific file’s stream.
- Return type
Iterator[WheelContentElement]
- class installer.sources.WheelFile(f)¶
Implements WheelSource, for an existing file from the filesystem.
Example usage:
>>> with WheelFile.open("sampleproject-2.0.0-py3-none-any.whl") as source: ... installer.install(source, destination)
- Parameters
f (zipfile.ZipFile) –
- Return type
- classmethod open(path)¶
Create a wheelfile from a given path.
- Parameters
path (FSPath) –
- Return type
Iterator[WheelFile]
- property dist_info_filenames¶
Get names of all files in the dist-info directory.
- read_dist_info(filename)¶
Get contents, from
filename
in the dist-info directory.- Parameters
filename (FSPath) –
- Return type
Text
- get_contents()¶
Sequential access to all contents of the wheel (including dist-info files).
This implementation requires that every file that is a part of the wheel archive has a corresponding entry in RECORD. If they are not, an
AssertionError
will be raised.- Return type
Iterator[WheelContentElement]