Help us shape the future of Go! Take the 2026 Go Developer Survey

python

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package python resolves CPython releases from the official python.org downloads API. The API is a single, anonymous JSON array of every release, each carrying a publication date (so cooldown applies) and a prerelease flag, with the version embedded in a "Python X.Y.Z" name.

The version's "Python " prefix is stripped and the result parsed to canonical semver, which restores the dash a python.org prerelease omits (3.15.0b3 -> 3.15.0-b3) so it orders and scheme-matches like any other prerelease.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option configures a Provider.

func WithTransport

func WithTransport(rt http.RoundTripper) Option

WithTransport overrides the HTTP transport, for tests.

type Provider

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

Provider resolves CPython versions from python.org's public, unauthenticated downloads API. The API is a single JSON array of every release, so the provider fetches it once and lets the framework own selection; it lists candidates and tags each with the publication date the API returns for free, which cooldown consumes.

func New

func New(opts ...Option) *Provider

New returns the Python provider. The downloads API is public and publishes no rate-limit headers, so the client is a plain cached one with no ratelimit wrapper or credentials.

func (*Provider) BareMajor added in v0.4.0

func (p *Provider) BareMajor()

BareMajor marks a bare single-number pin as major-precision rather than a calendar tag: python.org publishes X.Y.Z interpreters, never a calendar stamp, so a dotted candidate may replace one.

func (*Provider) Color added in v0.3.10

func (p *Provider) Color(dark bool) color.Color

Color is the provider's brand color. See provider.Provider.Color.

func (*Provider) Dated added in v0.2.8

func (p *Provider) Dated()

Dated marks the listing as date-bearing: every release carries a publication date, so cooldown applies.

func (*Provider) Describe

func (p *Provider) Describe(r provider.Resource) string

Describe returns a human-readable label for a resource.

func (*Provider) Discover

func (p *Provider) Discover(ctx context.Context, r provider.Resource) ([]model.Candidate, error)

Discover lists candidate CPython versions, reading the downloads API in one fetch. The API returns the whole release history in a single response, so there is no pagination and nothing is ever left unread - --deep has no work to do here.

func (*Provider) Identify added in v0.3.10

func (p *Provider) Identify(r provider.Resource) (string, string)

Identify names the Python runtime and its home page.

func (*Provider) Keys

func (p *Provider) Keys() []provider.Key

Keys reports the directive keys the provider accepts. python.org needs none of its own: the whole listing arrives in one fetch and it publishes no per-platform options.

func (*Provider) Name

func (p *Provider) Name() string

Name identifies the provider.

func (*Provider) Resource

func (p *Provider) Resource(d directive.Directive) (provider.Resource, error)

Resource validates a directive into a Python resource. python.org takes no provider-specific keys, so every directive resolves to the same descriptor. It rejects asset= up front: the downloads API publishes no release assets, so the filter could never match and every selection would fail confusingly.

func (*Provider) URL

URL builds the release page for a resolved candidate from its python.org slug (e.g. python-3146 -> .../downloads/release/python-3146/). A candidate without one - the synthesized current-version candidate carries no Meta - falls back to the slug derived from its version, so the from side links too.

Jump to

Keyboard shortcuts

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