Documentation
¶
Overview ¶
Package wheels provides configuration for sourcing cog and coglet wheels.
Index ¶
- Constants
- Variables
- func DetectLocalSDKVersion() string
- func IsPreRelease(version string) bool
- func SemverToPEP440(version string) string
- func ValidateSDKVersion(config *WheelConfig, label string) error
- type WheelConfig
- func GetCogWheelConfig() (*WheelConfig, error)
- func GetCogletWheelConfig(targetArch string) (*WheelConfig, error)
- func ParseWheelValue(value string) *WheelConfig
- func ResolveCogWheel(envValue string, version string) (*WheelConfig, error)
- func ResolveCogletWheel(envValue string, version string, platform string) (*WheelConfig, error)
- type WheelSource
Constants ¶
const CogSDKWheelEnvVar = "COG_SDK_WHEEL"
CogSDKWheelEnvVar is the environment variable name for cog SDK wheel selection
const CogletWheelEnvVar = "COGLET_WHEEL"
CogletWheelEnvVar is the environment variable name for coglet wheel selection
const MinimumSDKVersion = "0.16.0"
MinimumSDKVersion is the minimum cog SDK version that can be explicitly requested. Versions older than this lack features required by the current CLI.
const PreReleaseSentinel = "prerelease"
PreReleaseSentinel is the special sdk_version value that means "install the latest pre-release from PyPI" without pinning a version.
Variables ¶
var BaseVersionRe = regexp.MustCompile(`^(\d+\.\d+\.\d+)`)
BaseVersionRe extracts the MAJOR.MINOR.PATCH prefix, ignoring pre-release suffixes.
Functions ¶
func DetectLocalSDKVersion ¶ added in v0.17.0
func DetectLocalSDKVersion() string
DetectLocalSDKVersion checks dist/ (CWD and executable-relative) for a cog SDK wheel and extracts the version from its filename. Returns empty string if no local wheel is found.
func IsPreRelease ¶ added in v0.17.0
IsPreRelease returns true if the version string contains a pre-release identifier in either semver (-alpha1, -beta2, -rc1, -dev1) or PEP 440 (a1, b2, rc1, .dev1) format.
func SemverToPEP440 ¶ added in v0.17.0
SemverToPEP440 converts a semver pre-release version to PEP 440 format. e.g. "0.17.0-alpha1" -> "0.17.0a1", "0.17.0-beta2" -> "0.17.0b2", "0.17.0-rc1" -> "0.17.0rc1", "0.17.0-dev1" -> "0.17.0.dev1" Stable versions pass through unchanged: "0.17.0" -> "0.17.0"
func ValidateSDKVersion ¶ added in v0.17.0
func ValidateSDKVersion(config *WheelConfig, label string) error
ValidateSDKVersion checks that a PyPI WheelConfig does not request a version older than MinimumSDKVersion. Non-PyPI sources, unpinned versions, and nil configs are always valid.
Types ¶
type WheelConfig ¶
type WheelConfig struct {
// Source indicates where the wheel comes from
Source WheelSource
// URL is set when Source is WheelSourceURL
URL string
// Path is set when Source is WheelSourceFile (absolute path)
Path string
// Version is set when Source is WheelSourcePyPI (optional, empty = latest)
Version string
// PreRelease indicates that pip should use --pre to resolve the latest
// pre-release, without pinning a specific version.
PreRelease bool
}
WheelConfig represents the configuration for which wheel to install
func GetCogWheelConfig ¶ added in v0.17.0
func GetCogWheelConfig() (*WheelConfig, error)
GetCogWheelConfig is a convenience wrapper that reads COG_SDK_WHEEL from the environment and version from global.Version.
func GetCogletWheelConfig ¶ added in v0.17.0
func GetCogletWheelConfig(targetArch string) (*WheelConfig, error)
GetCogletWheelConfig is a convenience wrapper that reads COGLET_WHEEL from the environment and version from global.Version. targetArch is the GOARCH of the Docker build target (e.g. "amd64", "arm64") used to select the correct platform-specific wheel.
func ParseWheelValue ¶ added in v0.17.0
func ParseWheelValue(value string) *WheelConfig
ParseWheelValue parses a wheel env var value and returns the appropriate WheelConfig. Supported values:
- "pypi" - Install from PyPI (latest version)
- "pypi:0.12.0" - Install specific version from PyPI
- "https://..." or "http://..." - Direct wheel URL
- "/path/to/file.whl" or "relative/path" - Local file or directory (resolved to abspath)
Paths that point to directories are resolved later by the Resolve functions, which glob for the appropriate wheel inside the directory.
Returns nil if the value is empty (caller should use auto-detection).
func ResolveCogWheel ¶ added in v0.17.0
func ResolveCogWheel(envValue string, version string) (*WheelConfig, error)
ResolveCogWheel resolves the WheelConfig for the cog SDK.
Parameters:
- envValue: value of COG_SDK_WHEEL env var (empty string if not set)
- version: the CLI version (e.g. "dev", "0.17.0", "0.17.0-alpha1")
Resolution order:
- envValue (if non-empty, explicit override)
- Auto-detect: check dist/cog-*.whl (for development builds only)
- Default: PyPI latest (use build.sdk_version in cog.yaml to pin)
func ResolveCogletWheel ¶ added in v0.17.0
func ResolveCogletWheel(envValue string, version string, platform string) (*WheelConfig, error)
ResolveCogletWheel resolves the WheelConfig for coglet.
targetArch is the GOARCH of the Docker build target (e.g. "amd64", "arm64"). It is used to select the correct platform-specific wheel from dist/.
Resolution order:
- envValue (COGLET_WHEEL) if non-empty — explicit override
- Auto-detect: check ./dist for coglet-*.whl (development builds only)
- Default: PyPI latest (use COGLET_WHEEL=pypi:x.y.z to pin)
Coglet is always required. Returns a valid config or an error. The platform parameter is a GOARCH value (e.g. "amd64", "arm64") used to select the correct platform-specific wheel from a directory. Pass "" to skip filtering.
func (*WheelConfig) PyPIPackageURL ¶ added in v0.17.0
func (c *WheelConfig) PyPIPackageURL(packageName string) string
PyPIPackageURL returns the pip install specifier for a PyPI package. If version is empty, returns just the package name (latest). Otherwise returns "package==version" with the version converted to PEP 440.
type WheelSource ¶
type WheelSource int
WheelSource represents the source type for the wheel to install
const ( // WheelSourcePyPI installs from PyPI (default for released builds) WheelSourcePyPI WheelSource = iota // WheelSourceURL uses a custom URL WheelSourceURL // WheelSourceFile uses a local file path WheelSourceFile )
func (WheelSource) String ¶
func (s WheelSource) String() string
String returns the string representation of the WheelSource