🧬 merge_smithed_weld#
Merges the generated datapack and resource pack with their libraries using Smithed Weld.
- beet_default(ctx: Context) None[source]#
Merge Smithed Weld plugin for StewBeet. Merges the generated datapack and resource pack with libraries using Smithed Weld.
Welding a big pack costs seconds on every build, so prefer the split entry points
stewbeet.plugins.merge_smithed_weld.datapackand.resource_packand list only the pack types the project actually ships. Listing both is equivalent to this one.- Parameters:
ctx – The beet context.
silent#
weld#
- ALL_PACK_TYPES: tuple[str, ...] = ('datapack', 'resource_pack')[source]#
Pack types that can be merged with their libraries.
- WELDED_META_KEY: str = 'merge_smithed_weld_done'[source]#
ctx.meta key listing the pack types welded during this build.
- ASKED_PACK_TYPES: str = 'merge_smithed_weld_asked'[source]#
ctx.meta key listing the pack types that were asked to be welded.
- CACHE_NAME: str = 'stewbeet_weld'[source]#
Beet cache slot holding the signature of the sources each merged archive was built from.
- class WeldTask(
- sources: list[str],
- destination: str,
- pack_type: str,
- signature: str,
Bases:
objectOne merged archive to produce.
- gather_packs(
- ctx: Context,
- pack_type: str,
Collect the zip paths to merge for the given pack type (“datapack” or “resource_pack”).
Returns absolute paths, main pack last (so it overwrites pack format).
- weld_signature(sources: list[str]) str[source]#
Fingerprint the exact bytes that would be merged, so an unchanged merge can be skipped.
- Parameters:
sources – Absolute paths of the packs about to be merged, in merge order.
- Returns:
Hexadecimal digest covering every source name and content.
- Return type:
str
- is_merge_up_to_date(
- destination: str,
- signature: str,
- recorded: list[object] | None,
Whether the merged archive on disk was already produced from exactly these sources.
- Parameters:
destination – Path of the merged archive.
signature – Fingerprint of the sources about to be merged.
recorded – Cached [signature, size, mtime_ns] of the last merge, if any.
- Returns:
True when the merge can be skipped entirely.
- Return type:
bool
- weld_to(
- ctx: Context,
- sources: list[str],
- dest_path: str,
- pack_type: str,
Weld
sourcesintodest_pathin a single compression pass.Runs the Smithed Weld merge programmatically, then dumps the merged pack straight into a
ConstantTimeZipFile(constant timestamps, fixed pack.mcmeta and pack.png appended last) instead of letting weld save a temporary zip that would need to be fully re-deflated. Also avoids weld’s CLI-shared global cache directory, so multiple projects can build concurrently.
- prepare_weld(
- ctx: Context,
- dest_path: str,
- pack_type: str,
Gather the packs to merge, or return None (with a warning) when welding should be skipped.
- weld_pack(
- ctx: Context,
- dest_path: str,
- pack_type: str,
Merge a pack and its libs into one file using Weld.
- Parameters:
ctx – The beet context
dest_path – The path to the destination file
pack_type – Either “datapack” or “resource_pack”
- Returns:
The time it took to merge the pack and libs
- Return type:
float
- weld_datapack(
- ctx: Context,
- dest_path: str,
Merge the datapack and libs into one file using Weld :param ctx: The beet context :param dest_path: The path to the destination file
- Returns:
The time it took to merge the datapack and libs
- Return type:
float
- weld_resource_pack(
- ctx: Context,
- dest_path: str,
Merge the resource pack and libs into one file using Weld :param ctx: The beet context :param dest_path: The path to the destination file
- Returns:
The time it took to merge the resource pack and libs
- Return type:
float
- merged_archive_path(
- ctx: Context,
- pack_type: str,
Path of the
_with_libs.zipproduced for a pack type.- Parameters:
ctx – The beet context.
pack_type – Either “datapack” or “resource_pack”.
- Returns:
The absolute destination path of the merged archive.
- Return type:
str
- stashed_archive_path(
- ctx: Context,
- pack_type: str,
Where
drop_unwelded_archives()puts aside the merged archive of a pack type not welded yet.- Parameters:
ctx – The beet context.
pack_type – Either “datapack” or “resource_pack”.
- Returns:
A path in the weld cache, outside the output directory.
- Return type:
str
- drop_unwelded_archives(
- ctx: Context,
Move out of the output directory the merged archive of every pack type not welded so far.
A stale
_with_libs.zipleft in the output directory would be picked up bycompute_sha1and by a release upload, so it has to be gone before the rest of the pipeline looks at the output directory. It is only put aside, since an entry point welding that pack type later in the pipeline takes it back. Seerestore_stashed_archive().report_unwelded_archives()deletes what nobody took back and does the reporting, once every weld entry point ran.- Parameters:
ctx – The beet context.
- restore_stashed_archive(
- ctx: Context,
- pack_type: str,
Put back the merged archive an earlier weld entry point moved aside, before welding its pack type.
The archive keeps its size and modification time, so an unchanged merge is still skipped, and a merge that has to run reuses its unchanged entries (see
ConstantTimeZipFile).- Parameters:
ctx – The beet context.
pack_type – Either “datapack” or “resource_pack”.
- report_unwelded_archives(
- ctx: Context,
After the whole pipeline ran, report the pack types no entry point ever welded, and delete their archives put aside.
Registered once by
weld_pack_types()and resumed at the end of the build, so it sees every weld entry point that took part regardless of the order they appear in the pipeline.- Parameters:
ctx – The beet context.
- weld_pack_types(
- ctx: Context,
- pack_types: tuple[str, ...],
Merge the given pack types with their libraries.
- Parameters:
ctx – The beet context.
pack_types – The pack types to merge, among
ALL_PACK_TYPES.