Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonPackageName ¶
CanonPackageName returns the canonical form of the given PyPI package name.
func CanonVersion ¶
CanonVersion canonicalizes a version string. If the version does not parse according to PEP 440 it is returned as-is.
func SdistVersion ¶
SdistVersion attempts to extract the version from the name of an sdist file. The format of the names is not standardized, but it is a strong enough convention that pip relies on it (see https://github.com/pypa/pip/blob/0442875a68f19b0118b0b88c747bdaf6b24853ba/src/pip/_internal/index/package_finder.py#L978). The filenames are formatted <name>-<version>, where the name is not necessarily canonicalized. The returned version will be canonicalized if possible.
Types ¶
type Dependency ¶
Dependency is a dependency on a package.
func ParseDependency ¶
func ParseDependency(v string) (Dependency, error)
ParseDependency parses a python requirement statement according to PEP 508 (https://www.python.org/dev/peps/pep-0508/), apart from URL requirements.
type Metadata ¶
type Metadata struct {
// Name and Version are the only fields required by the spec.
// Taken directly from Metadata and not canonicalized.
Name, Version string
// Optional metadata as defined by the spec.
Summary string
Description string
Homepage string
Author string
AuthorEmail string
Maintainer string
MaintainerEmail string
License string
Classifiers []string
ProjectURLs []string
Dependencies []Dependency
}
Metadata holds metadata for a distribution as defined in https://packaging.python.org/specifications/core-metadata/.
func ParseMetadata ¶
ParseMetadata reads a METADATA or PKG-INFO file and collects as much information as possible. The earliest version of this format was a set of RFC 822 headers (see https://www.python.org/dev/peps/pep-0241/) with later versions (https://www.python.org/dev/peps/pep-0566/) adding the ability to include a message body rendering the format essentially the same as an email. The latest specification is here: https://packaging.python.org/en/latest/specifications/core-metadata/. For reference distlib, the library used by pip for this job, uses python's standard library email reader to read these files (see https://bitbucket.org/pypa/distlib/src/default/distlib/metadata.py). The current version of the specification requires metadata to be encoded as UTF-8, so an error will be returned if any invalid UTF-8 is discovered.
func SdistMetadata ¶
SdistMetadata attempts to read metadata out of the supplied reader assuming it contains an sdist. The reader should be either a tar or a zip file, the extension of the supplied filename will be used to distinguish.
func WheelMetadata ¶
WheelMetadata extracts the metadata from a wheel file. The file format is defined in PEP 427 (https://www.python.org/dev/peps/pep-0427/#file-format) and is relatively simple compared to sdists. In particular: wheels can not have a setup.py or setup.cfg and the metadata version must be 1.1 or greater. This means that the metadata definitely supports dependencies and there is nowhere else to specify them.
type PEP425Tag ¶
PEP425Tag holds a compatibility tag defined in https://www.python.org/dev/peps/pep-0425/
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is returned when we encounter data that fails to parse.
func (ParseError) Error ¶
func (p ParseError) Error() string
type UnsupportedError ¶
type UnsupportedError struct {
// contains filtered or unexported fields
}
UnsupportedError is an error used to indicate when we encounter types of packaging that we can not yet handle.
func (UnsupportedError) Error ¶
func (p UnsupportedError) Error() string
type WheelBuildTag ¶
WheelBuildTag holds the components of a wheel's build tag.
type WheelInfo ¶
type WheelInfo struct { Name string Version string BuildTag WheelBuildTag Platforms []PEP425Tag }
WheelInfo holds all of the information kept in the name of a wheel file.
func ParseWheelName ¶
ParseWheelName extracts all of the information in the name of a wheel. The wheel naming format is described in PEP 427 (https://www.python.org/dev/peps/pep-0427/#file-name-convention). The name and version will always be canonicalized if possible.