Ballistica Logo

baenv module

Manage ballistica execution environment.

This module is used to set up and/or check the global Python environment before running a ballistica app. This includes things such as paths, logging, and app-dirs. Because these things are global in nature, this should be done before any ballistica modules are imported.

This module can also be exec’ed directly to set up a default environment and then run the app.

Ballistica can be used without explicitly configuring the environment in order to integrate it in arbitrary Python environments, but this may cause some features to be disabled or behave differently than expected.

class baenv.EnvConfig(config_dir: str, data_dir: str, app_python_dir: str | None, standard_app_python_dir: str, site_python_dir: str | None, user_python_dir: str | None, is_user_app_python_dir: bool, log_handler: LogHandler | None, initial_app_config: Any)[source]

Bases: object

Final config values we provide to the engine.

app_python_dir: str | None
config_dir: str
data_dir: str
initial_app_config: Any
is_user_app_python_dir: bool
log_handler: LogHandler | None
site_python_dir: str | None
standard_app_python_dir: str
user_python_dir: str | None
baenv.config_exists() bool[source]

Has a config been created?

baenv.configure(*, config_dir: str | None = None, data_dir: str | None = None, user_python_dir: str | None = None, app_python_dir: str | None = None, site_python_dir: str | None = None, contains_python_dist: bool = False, setup_logging: bool = True) None[source]

Set up the environment for running a Ballistica app.

This includes things such as Python path wrangling and app directory creation. This must be called before any actual Ballistica modules are imported; the environment is locked in as soon as that happens.

baenv.did_paths_set_fail() bool[source]

Did we try to set paths and fail?

baenv.extract_arg(args: list[str], names: list[str], is_dir: bool) str | None[source]

Given a list of args and an arg name, returns a value.

The arg flag and value are removed from the arg list. We also check to make sure the path exists.

raises CleanErrors on any problems.

baenv.get_config() EnvConfig[source]

Return the active config, creating a default if none exists.