Install & Compatibility
Where this runs
tested against v2.34.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 63.7MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.7s · import 0.000s · 72MB
60MB installed
● package 60MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LifecycleManager
✓ from craft_parts import LifecycleManager
✗ from craft_parts.lifecycle import LifecycleManager
This quickstart demonstrates programmatically defining a simple 'hello' part that uses the 'dump' plugin to copy a source file. It then initializes a `LifecycleManager` to plan and execute the full crafting process (pull, build, stage, prime) within a temporary project structure, printing the output file.
import os
import pathlib
from craft_parts.models import PartSpec, Part
from craft_parts.lifecycle import LifecycleManager, Step
# Create a dummy project directory
project_dir = pathlib.Path('./my-craft-project')
project_dir.mkdir(exist_ok=True)
# Create a simple parts.yaml content
parts_yaml_content = '''
parts:
hello:
plugin: dump
source: hello.txt
'''
(project_dir / 'parts.yaml').write_text(parts_yaml_content)
(project_dir / 'hello.txt').write_text('Hello from Craft Parts!')
# Define the part specification programmatically
part_spec = PartSpec(
name="hello",
part=Part(
plugin="dump",
source="hello.txt"
)
)
# Initialize LifecycleManager
lcm = LifecycleManager(
parts={part_spec.name: part_spec.part},
application_name="my-craft-app",
project_dir=project_dir,
build_dir=project_dir / 'build',
stage_dir=project_dir / 'stage',
prime_dir=project_dir / 'prime',
cache_dir=project_dir / '.cache'
)
# Plan and execute the full lifecycle
actions = lcm.plan(Step.PRIME)
with lcm.action_executor() as aex:
aex.execute(actions)
print(f"Project built to: {project_dir / 'prime'}")
print(f"Content of staged file: {(project_dir / 'prime' / 'hello.txt').read_text()}")
Upgrade
Version history
2.34.0latest on PyPI · released Jun 11, 2026
Audit
Dependencies
craft-clirequiredCommand-line client builder framework.
craft-applicationrequiredApplication-level crafting utilities.
craft-providersrequiredManages software builds in containers.
craft-archivesrequiredManages interaction with software package repositories.
craft-grammarrequiredProvides Python interfaces for advanced grammar.
craft-platformsrequiredPlatform-specific utilities for crafting.
craft-storerequiredStorage utilities for crafting artifacts.
distrorequiredDetermines Linux distribution information.
pydanticrequiredData validation and settings management using Python type hints.
pyyamlrequiredYAML parser and emitter for Python.
requestsrequiredHTTP library for making web requests.
requests-toolbeltrequiredUtility belt for the Requests library.
simplejsonrequiredSimple, fast, extensible JSON encoder/decoder.
typing-extensionsrequiredBackports and experimental type hints.
validatorsrequiredValidation for various types of data.
attrsrequiredClasses without boilerplate.
jsonschemarequiredJSON Schema validation.
setuptoolsrequiredRequired for package metadata and setup utilities.