API Documentation

wheel.archive

Archive tools for wheel.

wheel.archive.archive_wheelfile(base_name, base_dir)

Archive all files under base_dir in a whl file and name it like base_name.

wheel.archive.make_wheelfile_inner(base_name, base_dir='.')

Create a whl file from all the files under ‘base_dir’.

Places .dist-info at the end of the archive.

wheel.install

Operations on existing wheel files, including basic installation.

class wheel.install.VerifyingZipFile(file, mode='r', compression=0, allowZip64=False)

ZipFile that can assert that each of its extracted contents matches an expected sha256 hash. Note that each file must be completly read in order for its hash to be checked.

open(name_or_info, mode='r', pwd=None)

Return file-like object for ‘name’.

pop()

Truncate the last file off this zipfile. Assumes infolist() is in the same order as the files (true for ordinary zip files created by Python)

set_expected_hash(name, hash)
Parameters:
  • name – name of zip entry
  • hash – bytes of hash (or None for “don’t care”)
wheel.install.WHEEL_INFO_RE()

match(string[, pos[, endpos]]) –> match object or None. Matches zero or more characters at the beginning of the string

class wheel.install.WheelFile(filename, fp=None, append=False, context=<function get_supported>)

Parse wheel-specific attributes from a wheel (.whl) file and offer basic installation and verification support.

WheelFile can be used to simply parse a wheel filename by avoiding the methods that require the actual file contents.

arity

The number of compatibility tags the wheel declares.

compatibility_rank(supported)

Rank the wheel against the supported tags. Smaller ranks are more compatible!

Parameters:supported – A list of compatibility tags that the current Python implemenation can run.
compatibility_tags

A wheel file is compatible with the Cartesian product of the period-delimited tags in its filename. To choose a wheel file among several candidates having the same distribution version ‘ver’, an installer ranks each triple of (pyver, abi, plat) that its Python installation can run, sorting the wheels by the best-ranked tag it supports and then by their arity which is just len(list(compatibility_tags)).

install(force=False, overrides={})

Install the wheel into site-packages.

install_paths

Consult distutils to get the install paths for our dist. A dict with (‘purelib’, ‘platlib’, ‘headers’, ‘scripts’, ‘data’).

We use the name from our filename as the dist name, which means headers could be installed in the wrong place if the filesystem-escaped name is different than the Name. Who cares?

parsed_wheel_info

Parse wheel metadata (the .data/WHEEL file)

rank

Lowest index of any of this wheel’s tags in self.context(), and the arity e.g. (0, 1)

tags

A wheel file is compatible with the Cartesian product of the period-delimited tags in its filename. To choose a wheel file among several candidates having the same distribution version ‘ver’, an installer ranks each triple of (pyver, abi, plat) that its Python installation can run, sorting the wheels by the best-ranked tag it supports and then by their arity which is just len(list(compatibility_tags)).

verify(zipfile=None)

Configure the VerifyingZipFile zipfile by verifying its signature and setting expected hashes for every hash in RECORD. Caller must complete the verification process by completely reading every file in the archive (e.g. with extractall).

wheel.install.parse_version(version)

Use parse_version from pkg_resources or distutils as available.

wheel.pkginfo

Tools for reading and writing PKG-INFO / METADATA without caring about the encoding.

wheel.util

Utility functions.

wheel.util.urlsafe_b64encode(data)

urlsafe_b64encode without padding

wheel.util.urlsafe_b64decode(data)

urlsafe_b64decode without padding

wheel.util.utf8(data)

Utf-8 encode data.

wheel.util.to_json(o)

Convert given data to JSON.

wheel.util.from_json(j)

Decode a JSON payload.

wheel.util.matches_requirement(req, wheels)

List of wheels matching a requirement.

Parameters:
  • req – The requirement to satisfy
  • wheels – List of wheels to search.