version

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Compare

func Compare(a, b *Version) int

Compare returns -1, 0, or 1 as a is less than, equal to, or greater than b, following the PEP 440 ordering rules.

func Equal

func Equal(a, b *Version) bool

Equal reports whether two versions are equal under PEP 440 ordering.

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

func ParseSpecifier(s string) (*Specifier, error)

ParseSpecifier parses one specifier such as ">=1.2.3".

func (*Specifier) Matches

func (s *Specifier) Matches(v *Version) bool

Matches reports whether the version satisfies this single specifier.

func (*Specifier) String

func (s *Specifier) String() string

String renders the specifier.

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

func MustParse(s string) *Version

MustParse parses a version and panics on failure. It is for tests and constants known to be valid.

func Parse

func Parse(s string) (*Version, error)

Parse parses a PEP 440 version string, normalizing as it goes.

func (*Version) BaseVersion

func (v *Version) BaseVersion() *Version

BaseVersion returns the epoch and release only, dropping pre, post, dev, and local segments.

func (*Version) HasLocal

func (v *Version) HasLocal() bool

HasLocal reports whether the version carries a local segment.

func (*Version) IsPostrelease

func (v *Version) IsPostrelease() bool

IsPostrelease reports whether the version has a post segment.

func (*Version) IsPrerelease

func (v *Version) IsPrerelease() bool

IsPrerelease reports whether the version is an alpha, beta, rc, or dev release.

func (*Version) Public

func (v *Version) Public() *Version

Public returns the version without its local segment.

func (*Version) String

func (v *Version) String() string

String returns the normalized PEP 440 form of the version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL