Common Build Operations¶
Build process common methods.
This module has been split into focused submodules for better organization. All public APIs are re-exported here for backward compatibility.
- class relenv.build.common.Dirs(dirs: WorkDirs, name: str, arch: str, version: str)¶
A container for directories during build time.
- Parameters:
dirs (
relenv.common.WorkDirs) – A collection of working directoriesname (str) – The name of this collection
arch (str) – The architecture being worked with
- property prefix: Path¶
Get the build prefix directory path.
- to_dict() Dict[str, Any]¶
Get a dictionary representation of the directories in this collection.
- Returns:
A dictionary of all the directories
- Return type:
dict
- property toolchain: Path | None¶
Get the toolchain directory path for the current platform.
- relenv.build.common.build_openssl(env: MutableMapping[str, str], dirs: Dirs, logfp: IO[str], fips: bool = False) None¶
Build openssl.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.build_openssl_fips(env: MutableMapping[str, str], dirs: Dirs, logfp: IO[str]) None¶
Build OpenSSL with FIPS module.
- relenv.build.common.build_sqlite(env: MutableMapping[str, str], dirs: Dirs, logfp: IO[str]) None¶
Build sqlite.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.create_archive(tarfp: TarFile, toarchive: str | PathLike[str], globs: Sequence[str], logfp: IO[str] | None = None) None¶
Create an archive.
- Parameters:
tarfp (file) – A pointer to the archive to be created
toarchive (str) – The path to the directory to archive
globs (list) – A list of filtering patterns to match against files to be added
logfp (file) – A pointer to the log file
- relenv.build.common.finalize(env: MutableMapping[str, str], dirs: Dirs, logfp: IO[str]) None¶
Run after we’ve fully built python.
This method enhances the newly created python with Relenv’s runtime hacks.
- Parameters:
env (dict) – The environment dictionary
dirs (
relenv.build.common.Dirs) – The working directorieslogfp (file) – A handle for the log file
- relenv.build.common.get_dependency_version(name: str, platform: str) Dict[str, str] | None¶
Get dependency version and metadata from python-versions.json.
Returns dict with keys: version, url, sha256, and any extra fields (e.g., sqliteversion) Returns None if dependency not found.
- Parameters:
name – Dependency name (openssl, sqlite, xz)
platform – Platform name (linux, darwin, win32)
- Returns:
Dict with version, url, sha256, and extra fields, or None
- relenv.build.common.install_runtime(sitepackages: str | PathLike[str]) None¶
Install a base relenv runtime.
- relenv.build.common.patch_file(path: str | PathLike[str], old: str, new: str) None¶
Search a file for a string to replace.
- Parameters:
path (str) – Location of the file to search
old (str) – The value that will be replaced (regex)
new – The value that will replace the ‘old’ value.
- relenv.build.common.update_ensurepip(directory: Path) None¶
Update bundled dependencies for ensurepip (pip & setuptools).
- relenv.build.common.update_sbom_checksums(source_dir: str | PathLike[str], files_to_update: MutableMapping[str, str | PathLike[str]]) None¶
Update checksums in sbom.spdx.json for modified files.
Python 3.12+ includes an SBOM (Software Bill of Materials) that tracks file checksums. When we update files (e.g., expat sources), we need to recalculate their checksums.
- Parameters:
source_dir (PathLike) – Path to the Python source directory
files_to_update (MutableMapping[str, PathLike]) – Mapping of SBOM relative paths to actual file paths