PackageService

The PackageService takes the final output of the prime step and assembles it into the final package. Because this step is unique to the app, the pack() and metadata() methods are abstract and must be implemented by the app.

API documentation

class craft_application.services.package.PackageService

The business logic for creating packages.

__init__(app: AppMetadata, services: ServiceFactory) None
abstract pack(prime_dir: Path, dest: Path) list[Path]

Create one or more packages.

Parameters:
  • prime_dir – Directory path to the default prime directory. DEPRECATED in favour of retrieving this information from the LifecycleService.

  • dest – Directory into which to write the package(s).

Returns:

A list of paths to the created packages.

property resource_map: dict[str, Path] | None

Map resource name to artifact file name.

write_state(artifact: Path | None, resources: dict[str, Path] | None) None

Write the packaging state.

read_state(platform: str | None = None) PackState

Read the packaging state.

Parameters:

platform – The name of the platform to read. If not provided, uses the first platform in the build plan.

Returns:

A PackState object containing the artifact and resources.

abstract property metadata: BaseMetadata

The metadata model for this project.

update_project() None

Update project fields with dynamic values set during the lifecycle.

write_metadata(path: Path) None

Write the project metadata to metadata.yaml in the given directory.

Parameters:

path – The path to the prime directory.