basilisp.main

basilisp.main is a Python module which includes functions for Bootstrapping the Basilisp runtime.

basilisp.main.bootstrap(target: str, opts: IPersistentMap[Keyword, bool] | None = None) None

Import a Basilisp namespace or function identified by target. If a function reference is given, the function will be called with no arguments.

Basilisp only needs to be initialized once per Python VM invocation. Subsequent imports of Basilisp namespaces will work using Python’s standard import statement and importlib.import_module() function.

target must be a string naming a Basilisp namespace. Namespace references may be given exactly as they are found in Basilisp code. target may optionally include a trailing function reference, delimited by “:”, which will be executed after the target namespace is imported.

opts is a mapping of compiler options that may be supplied for bootstrapping. This setting should be left alone unless you know what you are doing.

basilisp.main.bootstrap_python(site_packages: str | None = None) str

Bootstrap a Python installation by installing a .pth file in site-packages directory (corresponding to “purelib” in sysconfig.get_paths()). Returns the path to the .pth file.

Subsequent startups of the Python interpreter will have Basilisp already bootstrapped and available to run.

basilisp.main.init(opts: IPersistentMap[Keyword, bool] | None = None, force_reload: bool = False) None

Initialize the runtime environment for Basilisp code evaluation.

Basilisp only needs to be initialized once per Python VM invocation. Subsequent imports of Basilisp namespaces will work using Python’s standard import statement and importlib.import_module() function.

If you want to execute a Basilisp file which is stored in a well-formed package or module structure, you probably want to use bootstrap().

init() may be called more than once. Only the first invocation will initialize the runtime unless force_reload=True.

basilisp.main.unbootstrap_python(site_packages: str | None = None) str | None

Remove the basilispbootstrap.pth file found in the Python site-packages directory (corresponding to “purelib” in sysconfig.get_paths()). Return the path of the removed file, if any.