lightspeed.trex.packaging.core#

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

pydantic model lightspeed.trex.packaging.core.ModPackagingSchema#
Config:
  • extra: str = forbid

Fields:
  • context_name (str)

  • ignored_errors (list[tuple[str, str, str]] | None)

  • mod_details (str | None)

  • mod_layer_paths (list[pathlib.Path])

  • mod_name (str)

  • mod_version (str)

  • output_directory (pathlib.Path)

  • output_format (omni.flux.asset_importer.core.data_models.enums.UsdExtensions | None)

  • packaging_mode (lightspeed.trex.packaging.core.enum.ModPackagingMode)

  • rtxio_delete_dds_after_pack (bool)

  • rtxio_pack (bool)

  • rtxio_split_size_mb (lightspeed.trex.rtxio.core.items.RtxIoSplitSizePreset | None)

  • selected_layer_paths (list[pathlib.Path])

Validators:
  • at_least_one » mod_layer_paths

  • force_flatten_output_format » all fields

  • is_mod_file_valid » mod_layer_paths

  • is_not_empty » mod_name

  • is_not_empty » output_directory

  • is_valid_version » mod_version

  • layer_exists » selected_layer_paths

field context_name: str [Required]#

The context name to use for the packaging stage. Should be a unique context name.

Validated by:
  • force_flatten_output_format

field ignored_errors: list[tuple[str, str, str]] | None = None#

A list of errors to ignore when packaging the mod.

Validated by:
  • force_flatten_output_format

field mod_details: str | None = None#

Optional text used to describe the mod in more details.

Validated by:
  • force_flatten_output_format

field mod_layer_paths: list[Path] [Required]#

The mod layer paths should be ordered by opinion strength where the strongest layer is first. All mod layers found in a given project should be in found in the list, including external mod dependencies

Validated by:
  • at_least_one

  • force_flatten_output_format

  • is_mod_file_valid

field mod_name: str [Required]#

The display name used for the mod in the RTX Remix Runtime.

Validated by:
  • force_flatten_output_format

  • is_not_empty

field mod_version: str [Required]#

The mod version. Used when building dependency lists.

Validated by:
  • force_flatten_output_format

  • is_valid_version

field output_directory: Path [Required]#

The directory where the packaged mod should be stored.

WARNING: The directory will be emptied prior to packaging the mod.

Validated by:
  • force_flatten_output_format

  • is_not_empty

field output_format: UsdExtensions | None = UsdExtensions.USD#

How the packaged root USD layer should be written.

  • None: Keep the source mod root layer extension.

  • UsdExtensions.USD: Write the packaged root layer with the .usd extension.

  • UsdExtensions.USDA: Write the packaged root layer as human-readable .usda.

  • UsdExtensions.USDC: Write the packaged root layer as binary .usdc.

Validated by:
  • force_flatten_output_format

field packaging_mode: ModPackagingMode = ModPackagingMode.FLATTEN#

How external dependencies should be handled during packaging.

  • redirect: Keep external dependency references pointed at installed mods.

  • import: Copy dependency content into the package and preserve the layered USD output.

  • flatten: Copy dependency content into the package, flatten the packaged result into one layer, and prune unused assets that are no longer referenced after flattening.

Validated by:
  • force_flatten_output_format

field rtxio_delete_dds_after_pack: bool = False#

When True (and rtxio_pack is True), all .dds files are deleted from the output directory after successful RTX IO compression.

Validated by:
  • force_flatten_output_format

field rtxio_pack: bool = False#

When True, all DDS textures in the output directory are compressed into an RTX IO .pkg file after the standard packaging pipeline completes.

Validated by:
  • force_flatten_output_format

field rtxio_split_size_mb: RtxIoSplitSizePreset | None = None#

Optional RTX IO split-size preset, mapped to the packager’s –split argument.

Validated by:
  • force_flatten_output_format

field selected_layer_paths: list[Path] [Required]#

A list of layers to package. Must at least contain the strongest mod layer found in mod_layer_paths or the packaging process will quick return.

Validated by:
  • force_flatten_output_format

  • layer_exists

validator at_least_one  »  mod_layer_paths#

Check that at least 1 mod file was selected

validator is_mod_file_valid  »  mod_layer_paths#

Check that the file is a valid mod file

validator is_not_empty  »  mod_name, output_directory#

Check that the mod name is not empty

validator is_valid_version  »  mod_version#

Check that the mod version has a valid format

validator layer_exists  »  selected_layer_paths#

Check that every selected layer file exists

validator force_flatten_output_format  »  all fields#

Force flatten mode to the only output format that is safe for large projects.

Returns:

The validated packaging schema.

class lightspeed.trex.packaging.core.PackagingRepairCore(context_name: str = '')#

Core API for applying packaging repairs to editable project layers.

async apply_async(
repair_requests: Iterable[PackagingRepairRequest],
progress_callback: Callable[[int, int, PackagingRepairProgress], None] | None = None,
is_cancelled: Callable[[], bool] | None = None,
) PackagingRepairResult | None#

Apply packaging repairs on a worker thread.

Parameters:
  • repair_requests – Repair requests selected by the user.

  • progress_callback – Optional callback receiving current item count, total item count, and progress state.

  • is_cancelled – Optional callback returning whether the user requested cancellation.

Returns:

The repair result, or None if the repair was cancelled before saving.

Raises:

RuntimeError – If layers have unsaved edits or a target layer cannot be opened or saved.

asset_is_in_project_dir(
layer_identifier: str,
asset_path: str,
include_deps_dir: bool = False,
) bool#

Check whether an asset is inside the current project directory.

Parameters:
  • layer_identifier – Identifier for the layer that authored the unresolved asset.

  • asset_path – Asset path to inspect.

  • include_deps_dir – Whether to count the project deps directory as a project path.

Returns:

Whether the asset is inside the project directory.

destroy()#

Destroy held cores and release their subscriptions.

is_file_path_valid(
layer_identifier: str,
asset_path: str,
log_error: bool = True,
) bool#

Check whether an asset path points to a readable file.

Parameters:
  • layer_identifier – Identifier for the layer the asset path is relative to.

  • asset_path – Asset path to inspect.

  • log_error – Whether validation failures should be logged.

Returns:

Whether the asset path is readable.

raise_if_layers_dirty()#

Raise when any live USD layer has unsaved edits.

Raises:

RuntimeError – If the current layer stack has pending edits.

was_asset_ingested(
asset_path: str,
ignore_invalid_paths: bool = True,
) bool#

Check whether an asset has valid ingestion metadata.

Parameters:
  • asset_path – Asset path to inspect.

  • ignore_invalid_paths – Whether invalid paths should be treated as ingested.

Returns:

Whether the asset is ingested.