Skip to content
ocx
install

DistSource (1 of 2)

DistSourceclassdataclass#

Re-exported from ocx_sdk._distView source

authattributeclass attributeinstance attribute#

auth: Auth | None = field(default=None, repr=False)

headersattributeclass attributeinstance attribute#

headers: Mapping[str, str] = field(default=_NO_HEADERS, repr=False)

credentialsmethod#

def credentials(env: Mapping[str, str] | None = None) -> Credentials

Return this source’s credentials, bound to its resolved origin.

Parameters

NameTypeDefaultDescription
envMapping[str, str] | NoneNoneEnvironment used to resolve the URL, as in resolve_url.

Returns

Credentials
Credentials whose origin is the resolved URL’s, or an unbound empty
Credentials
set for a local or in-memory source.

Raises

DistManifestError
The resolved URL is not usable — not https, or carrying userinfo.

datamethodclassmethod#

def data(raw: bytes, sha256: str | None = None) -> DistSource

Use manifest bytes the caller already has.

The vendoring path: ship a dist/<sha256>.json snapshot as package data and read it back with importlib.resources, which works from a zipped wheel where a filesystem path does not.

Parameters

NameTypeDefaultDescription
rawbytesrequiredThe manifest body.
sha256str | NoneNoneExpected digest of raw.

Returns

DistSource
The source.

Raises

DistManifestError
sha256 is not 64 lowercase hex digits.

pathmethodclassmethod#

def path(path: Path | str, sha256: str | None = None) -> DistSource

Read the manifest from a local file.

Parameters

NameTypeDefaultDescription
pathPath | strrequiredFile holding the manifest JSON.
sha256str | NoneNoneExpected digest of the file contents.

Returns

DistSource
The source.

Raises

DistManifestError
sha256 is not 64 lowercase hex digits.

resolve_urlmethod#

def resolve_url(env: Mapping[str, str] | None = None) -> str | None

Return the URL this source fetches from.

Parameters

NameTypeDefaultDescription
envMapping[str, str] | NoneNoneEnvironment consulted for OCX_INSTALL_DIST_URL; only a source without an explicit location reads it.

Returns

str | None
The manifest URL, or None for a local or in-memory source.