sonolus.script.project¶
BuildConfig
dataclass
¶
A configuration for building an engine package.
FAST_PASSES: optimize.OptimizationLevel = optimize.FAST_PASSES
class-attribute
¶
The fast optimization level for quicker builds (-O1).
MINIMAL_PASSES: optimize.OptimizationLevel = optimize.MINIMAL_PASSES
class-attribute
¶
The minimal optimization level (-O0).
STANDARD_PASSES: optimize.OptimizationLevel = optimize.STANDARD_PASSES
class-attribute
¶
The standard optimization level (-O2).
build_play: bool = True
class-attribute
instance-attribute
¶
Whether to build the play package.
build_preview: bool = True
class-attribute
instance-attribute
¶
Whether to build the preview package.
build_tutorial: bool = True
class-attribute
instance-attribute
¶
Whether to build the tutorial package.
build_watch: bool = True
class-attribute
instance-attribute
¶
Whether to build the watch package.
override_resource_level_engines: bool = True
class-attribute
instance-attribute
¶
Whether to override any levels included in resources to use the engine of this project.
passes: optimize.OptimizationLevel = optimize.STANDARD_PASSES
class-attribute
instance-attribute
¶
The optimization level to use.
runtime_checks: RuntimeChecks = RuntimeChecks.NONE
class-attribute
instance-attribute
¶
Runtime error checking mode.
verbose: bool = False
class-attribute
instance-attribute
¶
Whether the dev server prints full tracebacks for compilation errors instead of a simplified summary.
Project
¶
A Sonolus.py project.
resources and converters are read only by dev, which serves the
resources alongside the project's own engine and levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine
|
Engine
|
The engine of the project. |
required |
levels
|
Iterable[Level] | Callable[[], Iterable[Level]] | None
|
The levels of the project. Their names must be unique. |
None
|
resources
|
str | PathLike[str] | None
|
The path to the resources of the project. |
None
|
converters
|
dict[str | None, Callable[[ExternalLevelData], LevelData | None]] | None
|
A dict mapping source engine names to functions converting the
|
None
|
levels: list[Level]
property
¶
The project's levels, loaded and cached on first access.
build(build_dir: str | PathLike[str], config: BuildConfig | None = None)
¶
Build the project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
build_dir
|
str | PathLike[str]
|
The path to the build directory. |
required |
config
|
BuildConfig | None
|
The build configuration. |
None
|
dev(build_dir: str | PathLike[str], port: int = 8080, config: BuildConfig | None = None)
¶
Start a development server for the project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
build_dir
|
str | PathLike[str]
|
The path to the build directory. |
required |
port
|
int
|
The port of the development server. |
8080
|
config
|
BuildConfig | None
|
The build configuration. If unset, defaults to runtime checks that log, pause, and terminate
on errors, unlike |
None
|
schema() -> ProjectSchema
¶
Generate the schema of the project.
Returns:
| Type | Description |
|---|---|
ProjectSchema
|
The |
with_levels(levels: Iterable[Level] | Callable[[], Iterable[Level]] | None) -> Project
¶
ProjectSchema
¶
Bases: TypedDict
The schema of a project, as returned by Project.schema.
archetypes: list[ArchetypeSchema]
instance-attribute
¶
The schemas of the project's archetypes.
lazy_loader(fn)
¶
Lazily yield the levels produced by the given callable.