pypi

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxWorkers = 10
	DefaultTimeout    = 30 * time.Second
	DefaultUserAgent  = "angela/0.1.0 (https://github.com/CarterPerez-dev/angela)"
)

PyPI client configuration defaults.

View Source
const DefaultCacheTTL = 1 * time.Hour

DefaultCacheTTL defines how long cached PyPI responses remain valid

Variables

View Source
var ErrInvalidVersion = errors.New("invalid PEP 440 version")

ErrInvalidVersion indicates a string that does not conform to PEP 440

Functions

func NormalizeName

func NormalizeName(name string) string

NormalizeName converts a PyPI package name to its canonical form per PEP 503

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache provides file-backed storage for PyPI API responses with ETag support

func NewCache

func NewCache(dir string, ttl time.Duration) (*Cache, error)

NewCache creates a file-backed cache at the given directory

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cached entries from disk

func (*Cache) Get

func (c *Cache) Get(key string) (*CacheEntry, bool)

Get retrieves a cache entry by package name, returning false on miss

func (*Cache) IsFresh

func (c *Cache) IsFresh(entry *CacheEntry) bool

IsFresh reports whether the entry is still within its TTL window

func (*Cache) Set

func (c *Cache) Set(key string, entry *CacheEntry) error

Set writes a cache entry atomically using rename-over-temp

func (*Cache) Touch

func (c *Cache) Touch(key string)

Touch refreshes the CachedAt timestamp without changing stored data

type CacheEntry

type CacheEntry struct {
	ETag     string    `json:"etag"`
	Versions []string  `json:"versions"`
	CachedAt time.Time `json:"cached_at"`
}

CacheEntry holds a cached PyPI response alongside its freshness metadata

type ChangeKind

type ChangeKind int

ChangeKind classifies a version bump by semver magnitude

const (
	Patch ChangeKind = iota + 1
	Minor
	Major
)

Version change magnitudes.

func ClassifyChange

func ClassifyChange(from, to Version) ChangeKind

ClassifyChange determines whether moving from v to other is a major, minor, or patch bump based on their release segments

func (ChangeKind) String

func (c ChangeKind) String() string

String returns the lowercase name of the change kind

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client queries the PyPI Simple API for package version information

func NewClient

func NewClient(cacheDir string) (*Client, error)

NewClient creates a PyPI client backed by a file cache at cacheDir

func (*Client) ClearCache

func (c *Client) ClearCache() error

ClearCache removes all cached PyPI responses

func (*Client) FetchAllVersions

func (c *Client) FetchAllVersions(
	ctx context.Context,
	names []string,
) []FetchResult

FetchAllVersions queries multiple packages concurrently and returns per-package results. Failures for individual packages do not prevent the remaining packages from being fetched.

func (*Client) FetchVersions

func (c *Client) FetchVersions(
	ctx context.Context,
	name string,
) ([]string, error)

FetchVersions returns all known versions for a single PyPI package

type FetchResult

type FetchResult struct {
	Name     string
	Versions []string
	Err      error
}

FetchResult holds the outcome of querying a single package

type Version

type Version struct {
	Raw     string
	Epoch   int
	Release []int
	PreKind string
	PreNum  int
	Post    int
	Dev     int
	Local   string
}

Version represents a parsed PEP 440 version with all optional components

func LatestStable

func LatestStable(versions []string) (Version, error)

LatestStable finds the highest stable version from a list of version strings

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a PEP 440 version string into its structured components

func (Version) Compare

func (v Version) Compare(other Version) int

Compare returns -1, 0, or 1 following PEP 440 ordering rules.

The ordering within a given release segment is:

1.0.dev1 < 1.0a1 < 1.0b1 < 1.0rc1 < 1.0 < 1.0.post1

func (Version) IsStable

func (v Version) IsStable() bool

IsStable reports whether the version is a stable (non-pre, non-dev) release

func (Version) String

func (v Version) String() string

String returns the canonical PEP 440 representation

Jump to

Keyboard shortcuts

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