Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

PEP 427 -- The Wheel Binary Package Format 1.0

$
0
0

Comments:"PEP 427 -- The Wheel Binary Package Format 1.0"

URL:http://www.python.org/dev/peps/pep-0427/


The wheel filename is {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl.

distribution Distribution name, e.g. 'django', 'pyramid'. version Distribution version, e.g. 1.0. build tag Optional build number. Must start with a digit. A tie breaker if two wheels have the same version. Sort as the empty string if unspecified, else sort the initial digits as a number, and the remainder lexicographically. language implementation and version tag E.g. 'py27', 'py2', 'py3'. abi tag E.g. 'cp33m', 'abi3', 'none'. platform tag E.g. 'linux_x86_64', 'any'.

For example, distribution-1.0-1-py27-none-any.whl is the first build of a package called 'distribution', and is compatible with Python 2.7 (any Python 2.7 implementation), with no ABI (pure Python), on any CPU architecture.

The last three components of the filename before the extension are called "compatibility tags." The compatibility tags express the package's basic interpreter requirements and are detailed in PEP 425.

Each component of the filename is escaped by replacing runs of non-alphanumeric characters with an underscore _:

re.sub("[^\w\d.]+", "_", distribution, re.UNICODE)

The filename is Unicode. It will be some time before the tools are updated to support non-ASCII filenames, but they are supported in this specification.

The contents of a wheel file, where {distribution} is replaced with the name of the package, e.g. beaglevote and {version} is replaced with its version, e.g. 1.0.0, consist of:

/, the root of the archive, contains all files to be installed in purelib or platlib as specified in WHEEL. purelib and platlib are usually both site-packages. {distribution}-{version}.dist-info/ contains metadata. {distribution}-{version}.data/ contains one subdirectory for each non-empty install scheme key not already covered, where the subdirectory name is an index into a dictionary of install paths (e.g. data, scripts, include, purelib, platlib). Python scripts must appear in scripts and begin with exactly b'#!python' in order to enjoy script wrapper generation and #!python rewriting at install time. They may have any or no extension. {distribution}-{version}.dist-info/METADATA is Metadata version 1.1 or greater format metadata. {distribution}-{version}.dist-info/WHEEL is metadata about the archive itself in the same basic key: value format: Wheel-Version: 1.0 Generator: bdist_wheel 1.0 Root-Is-Purelib: true Tag: py2-none-any Tag: py3-none-any Build: 1 Wheel-Version is the version number of the Wheel specification. Generator is the name and optionally the version of the software that produced the archive. Root-Is-Purelib is true if the top level directory of the archive should be installed into purelib; otherwise the root should be installed into platlib. Tag is the wheel's expanded compatibility tags; in the example the filename would contain py2.py3-none-any. Build is the build number and is omitted if there is no build number. A wheel installer should warn if Wheel-Version is greater than the version it supports, and must fail if Wheel-Version has a greater major version than the version it supports. Wheel, being an installation format that is intended to work across multiple versions of Python, does not generally include .pyc files. Wheel does not contain setup.py or setup.cfg.

This version of the wheel specification is based on the distutils install schemes and does not define how to install files to other locations. The layout offers a superset of the functionality provided by the existing wininst and egg binary formats.

Wheel .dist-info directories include at a minimum METADATA, WHEEL, and RECORD. METADATA is the package metadata, the same format as PKG-INFO as found at the root of sdists. WHEEL is the wheel metadata specific to a build of the package. RECORD is a list of (almost) all the files in the wheel and their secure hashes. Unlike PEP 376, every file except RECORD, which cannot contain a hash of itself, must include its hash. The hash algorithm must be sha256 or better; specifically, md5 and sha1 are not permitted, as signed wheel files rely on the strong hashes in RECORD to validate the integrity of the archive. PEP 376's INSTALLER and REQUESTED are not included in the archive. RECORD.jws is used for digital signatures. It is not mentioned in RECORD. RECORD.p7s is allowed as a courtesy to anyone who would prefer to use S/MIME signatures to secure their wheel files. It is not mentioned in RECORD. During extraction, wheel installers verify all the hashes in RECORD against the file contents. Apart from RECORD and its signatures, installation will fail if any file in the archive is not both mentioned and correctly hashed in RECORD.

Any file that is not normally installed inside site-packages goes into the .data directory, named as the .dist-info directory but with the .data/ extension:

distribution-1.0.dist-info/
distribution-1.0.data/

The .data directory contains subdirectories with the scripts, headers, documentation and so forth from the distribution. During installation the contents of these subdirectories are moved onto their destination paths.


Viewing all articles
Browse latest Browse all 9433

Trending Articles