rules/python/pex_toolchain.js

Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.

PEX_TOOL

const PEX_TOOL

Undocumented.

pexCacheKey()

pexCacheKey(version)

Undocumented.

pexDownloadUrl()

pexDownloadUrl(version)

Return the pex zipapp download URL for a version.

ParameterTypeDescription
versionstring

Returns: string

PexToolchain (implementation class)

class PexToolchain

Implementation class. BUILD files should use pexToolchain().

Undocumented.

pexToolchain()

pexToolchain(version, opts = {})

Declare a pex toolchain version and optionally set it as the default. defaults to the bundled //rules/python/pex-toolchain.lock. Point this at your own lock (regenerate via imp goal gen-lockfiles) when pinning a version the bundled lock does not know. matching lockfile entry (warns instead of failing).

ParameterTypeDescription
versionstring
[opts]object
[opts.default=false]boolean
[opts.lockfile]stringLockfile address pinning download SHA-256s;
[opts.unverified=false]booleanAllow downloading without a

Returns: object Target handle for this pex toolchain.

pexGenLockfiles()

pexGenLockfiles(version, opts = {})

The [GEN_LOCKFILES] root for a pex toolchain version. This is a separate function from pexToolchain(). pexToolchain() returns a frozen tool() handle. A frozen object cannot hold an extra property. one declared on the toolchain. Defaults to the address pexToolchain(version, { lockfile }) declared, so a workspace states it once.

ParameterTypeDescription
[version]string
[opts]object
[opts.lockfile]stringWrite this lockfile address instead of the

Returns: object { [GEN_LOCKFILES]: ... }.

pexGraphTool()

pexGraphTool(version)

Return the CAS-backed graph PEX tool.

installPexToolchain()

installPexToolchain(version, source)

Install a local pex zipapp into the named cache.

ParameterTypeDescription
versionstring
sourcestringPath to the pex zipapp file.

Returns: string|null Local path to the cached zipapp.

resolvePexToolchainVersion()

resolvePexToolchainVersion(version)

Resolve an explicit or default pex toolchain version.

ParameterTypeDescription
[version]string

Returns: string|null

pexRootTool()

pexRootTool()

Return a named-cache-backed tool descriptor mounting PEX's shared PEX_ROOT cache at a stable path, read-write across every sandbox. Not put on PATH (binDirs empty) — pair with pexRootEnv() to point $PEX_ROOT at its mount path. WARNING: this cache has no seed task. A tool mount needs its cache path to exist as a real directory (materialize_tools_into_sandbox in src/exec.rs fails otherwise), so the first run() that mounts it will fail. There are no callers today; give the cache a graph seed task before you add one.

Returns: object

pexRootEnv()

pexRootEnv()

Return the run() env entries pointing pex at its shared PEX_ROOT tool mount (see pexRootTool). Any run() using this must also include that tool, or the path won't exist in the sandbox. Values are relative to the sandbox root — callers must export them as absolute paths (capturing $(pwd) before any cd) rather than passing them via run()'s own env:, exactly as zigGlobalCacheEnv()'s doc comment in rules/c/zig/index.js explains for ZIG_GLOBAL_CACHE_DIR.

Returns: string[]

defaultPexToolchainVersion()

defaultPexToolchainVersion()

Return the currently configured default pex toolchain version.

Returns: string|null

defaultPexToolchain()

defaultPexToolchain()

Return the currently configured default pex toolchain target handle.

Returns: object|null