Documentation
¶
Overview ¶
Package wheels provides configuration for sourcing cog and coglet wheels.
Index ¶
- Constants
- func SemverToPEP440(version string) string
- type WheelConfig
- func GetCogWheelConfig() (*WheelConfig, error)
- func GetCogletWheelConfig() (*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 CogWheelEnvVar = "COG_WHEEL"
CogWheelEnvVar is the environment variable name for cog SDK wheel selection
const CogletWheelEnvVar = "COGLET_WHEEL"
CogletWheelEnvVar is the environment variable name for coglet wheel selection
Variables ¶
This section is empty.
Functions ¶
func SemverToPEP440 ¶
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"
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
}
WheelConfig represents the configuration for which wheel to install
func GetCogWheelConfig ¶
func GetCogWheelConfig() (*WheelConfig, error)
GetCogWheelConfig is a convenience wrapper that reads COG_WHEEL from the environment and version from global.Version.
func GetCogletWheelConfig ¶
func GetCogletWheelConfig() (*WheelConfig, error)
GetCogletWheelConfig is a convenience wrapper that reads COGLET_WHEEL from the environment and version from global.Version. Does not filter by platform — use ResolveCogletWheel directly when platform selection is needed (e.g. Dockerfile generation).
func ParseWheelValue ¶
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 ¶
func ResolveCogWheel(envValue string, version string) (*WheelConfig, error)
ResolveCogWheel resolves the WheelConfig for the cog SDK.
Parameters:
- envValue: value of COG_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 (with version pin for release builds)
func ResolveCogletWheel ¶
func ResolveCogletWheel(envValue string, version string, platform string) (*WheelConfig, error)
ResolveCogletWheel resolves the WheelConfig for coglet.
Resolution order:
- envValue (COGLET_WHEEL) if non-empty — explicit override
- Auto-detect: check ./dist for coglet-*.whl (development builds only)
- Default: PyPI (with version pinned for release builds)
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 ¶
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