Documentation
¶
Overview ¶
Package pypi fetches package metadata from a Python package index using the JSON API. It pools connections, retries transient failures with exponential backoff, and can fetch many releases concurrently. A Source interface lets the resolver run against the network client or an in-memory source in tests.
Index ¶
- Constants
- Variables
- type Client
- type MemSource
- func (m *MemSource) Add(info *ReleaseInfo)
- func (m *MemSource) AddPackage(name, ver string, deps ...string) error
- func (m *MemSource) Release(_ context.Context, name string, v *version.Version) (*ReleaseInfo, error)
- func (m *MemSource) Versions(_ context.Context, name string) ([]*version.Version, error)
- type Option
- type Ref
- type ReleaseInfo
- type Result
- type Source
Constants ¶
const DefaultBaseURL = "https://pypi.org/pypi"
DefaultBaseURL is the JSON API root of the public Python Package Index.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a package or release does not exist.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fetches metadata from a JSON package index.
func NewClient ¶
NewClient creates a client with connection pooling suited to fetching many small metadata documents.
func (*Client) FetchReleases ¶
FetchReleases fetches many releases concurrently, bounded by concurrency. The results are returned in the same order as refs.
type MemSource ¶
type MemSource struct {
// contains filtered or unexported fields
}
MemSource is an in-memory Source. It backs tests and offline resolution from a local set of packages, such as a wheelhouse referenced with find-links.
func (*MemSource) Add ¶
func (m *MemSource) Add(info *ReleaseInfo)
Add records a release. The package name is canonicalized for lookup.
func (*MemSource) AddPackage ¶
AddPackage is a convenience for registering a release from strings.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL sets the JSON API root, for a mirror or a private index.
func WithHTTPClient ¶
WithHTTPClient supplies a custom HTTP client.
func WithMaxRetries ¶
WithMaxRetries sets how many times a transient failure is retried.
func WithMinBackoff ¶
WithMinBackoff sets the initial backoff delay, which doubles per retry.
type ReleaseInfo ¶
type ReleaseInfo struct {
Name string
Version *version.Version
RequiresPython string
RequiresDist []*requirement.Requirement
Yanked bool
}
ReleaseInfo is the metadata gopip needs about one release of a package.
type Result ¶
type Result struct {
Ref Ref
Info *ReleaseInfo
Err error
}
Result pairs a Ref with its fetched metadata or an error.
type Source ¶
type Source interface {
// Versions returns all available versions of a package, ascending.
Versions(ctx context.Context, name string) ([]*version.Version, error)
// Release returns the metadata for a specific version.
Release(ctx context.Context, name string, v *version.Version) (*ReleaseInfo, error)
}
Source provides package versions and release metadata.