conda_recipe_manager.ops.version_bumper#
- Description:
Provides library tooling to perform recipe version updates or recipe "bumps". Most of the work found here originates from the crm bump-recipe command line interface.
Classes
|
Library class that simplifies the process of upgrading a recipe file to a new version. |
|
Set of flags that dictate how the VersionBumper class operates. |
- class conda_recipe_manager.ops.version_bumper.VersionBumper(recipe_path: Path | str, options: VersionBumperOption | None = None)[source]#
Bases:
objectLibrary class that simplifies the process of upgrading a recipe file to a new version. This class handles file I/O and will commit changes directly to a target recipe file. It also handles acquiring and managing remote source artifacts specified in the /source section of the target recipe file.
This work was all originally found in the crm bump-recipe command and has been refactored into its own library module for easier consumption by other automated systems.
- commit_changes() None[source]#
Saves the current recipe state to the target recipe file OR prints the contents of the file to STDOUT when the VersionBumperOption.DRY_RUN_MODE option is enabled.
- get_recipe_reader() RecipeReaderDeps[source]#
Exposes the underlying recipe parser instance for read-only access to a recipe file. This can help bootstrap the factory functions found the conda_recipe_manager.fetcher.artifact_fetcher module
NOTE: Read-only capabilities are enforced by type-checkers (like mypy) only.
- Returns:
A read-only recipe parser instance.
- update_build_num(build_num: int | None) None[source]#
Attempts to update the build number in a recipe file.
- Parameters:
build_num -- Build number to set. When set to None, this auto-increments the current build number. Otherwise, this value must be a >= 0.
- Raises:
VersionBumperInvalidState -- If the build number field could not be set because the recipe file is in or would be put into an invalid state.
VersionBumperPatchError -- If there was a failure attempting to edit the /build/number field.
SentinelTypeEvaluationException -- If a node value with a sentinel type is evaluated.
- update_http_urls(futures_tbl: dict[Future[tuple[BaseArtifactFetcher, str | None]], str]) None[source]#
Updates any outdated URLs found in the recipe file. Should be used in conjunction with from_recipe_fetch_corrected(), which attempts to flag outdated URLs and find their replacement URLs.
- NOTE: Most of the URLs updated are tied to changes made by PyPI over the years, including a significant change
to the package naming conventions made in 2024.
NOTE: This function will block on network I/O.
- Parameters:
futures_tbl -- Table of future fetchers, generated by one of the factory functions found in the conda_recipe_manager.fetcher.artifact_fetcher module.
- Raises:
FetchError -- If there was a failure to acquire the remote source artifacts needed by this call.
VersionBumperInvalidState -- If the futures table provided is invalid.
VersionBumperPatchError -- If there was a failure to update the underlying recipe file.
- update_sha256(futures_tbl: dict[Future[tuple[BaseArtifactFetcher, str | None]], str]) None[source]#
Attempts to update the SHA-256 hash(s) in the /source section of a recipe file, if applicable. Note that this is only required for build artifacts that are hosted as compressed software archives.
NOTE: This function will block on network I/O. NOTE: For this to make any meaningful changes, the version field will need to be updated first.
- Parameters:
futures_tbl -- Table of future fetchers, generated by one of the factory functions found in the conda_recipe_manager.fetcher.artifact_fetcher module.
- Raises:
FetchError -- If there was a failure to acquire the remote source artifacts needed by this call.
VersionBumperInvalidState -- If the futures table provided is invalid.
VersionBumperPatchError -- If there was a failure to update the underlying recipe file.
- update_version(target_version: str) None[source]#
Attempts to update the /package/version field and/or the commonly used version JINJA variable.
- Parameters:
target_version -- Target version string to set the recipe file to. Must be non-empty and this must be different than the current version string.
- Raises:
VersionBumperInvalidState -- If the target version could not be set because the recipe file is in or would be put into an invalid state.
VersionBumperPatchError -- If there was a failure attempting to edit the target version.
SentinelTypeEvaluationException -- If a node value with a sentinel type is evaluated.