Documentation
¶
Overview ¶
Package version implements Python version handling as defined by PEP 440: parsing, normalization, ordering, and version specifier sets. The rules here match the behavior of the reference packaging library so that gopip resolves the same versions pip would.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Specifier ¶
type Specifier struct {
// contains filtered or unexported fields
}
Specifier is a single version constraint such as >=1.2 or ==1.4.*.
func ParseSpecifier ¶
ParseSpecifier parses one specifier such as ">=1.2.3".
type SpecifierSet ¶
type SpecifierSet struct {
// contains filtered or unexported fields
}
SpecifierSet is a comma-separated list of specifiers, all of which must match.
func ParseSpecifierSet ¶
func ParseSpecifierSet(s string) (*SpecifierSet, error)
ParseSpecifierSet parses a comma-separated set such as ">=1.0,<2.0".
func (*SpecifierSet) Contains ¶
func (set *SpecifierSet) Contains(v *Version, allowPre bool) bool
Contains reports whether the version satisfies every specifier. Pre-release versions are rejected unless allowPre is true or the set references a pre-release.
func (*SpecifierSet) ExactVersions ¶ added in v0.1.1
func (set *SpecifierSet) ExactVersions() []*Version
ExactVersions returns the versions this set pins with ==, which is how a requirement names one exact release rather than a range. A wildcard such as ==1.4.* names a range, so it is not a pin.
func (*SpecifierSet) Matches ¶
func (set *SpecifierSet) Matches(v *Version) bool
Matches reports whether the version satisfies every specifier, excluding pre-releases unless the set opts into them.
func (*SpecifierSet) String ¶
func (set *SpecifierSet) String() string
String renders the specifier set.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version is a parsed PEP 440 version.
func MustParse ¶
MustParse parses a version and panics on failure. It is for tests and constants known to be valid.
func (*Version) BaseVersion ¶
BaseVersion returns the epoch and release only, dropping pre, post, dev, and local segments.
func (*Version) IsPostrelease ¶
IsPostrelease reports whether the version has a post segment.
func (*Version) IsPrerelease ¶
IsPrerelease reports whether the version is an alpha, beta, rc, or dev release.