Skip to content

pytauri_wheel.lib

PyTauri precompiled wheels.

Usage

pytauri-wheel provides precompiled pytauri.EXT_MOD for pytauri, which means you can normally use the pytauri API, except for the following APIs provided by pytauri-wheel:

Functions:

Name Description
builder_factory

A factory function for creating a pytauri.Builder instance.

context_factory

Generate a Context based on tauri.conf.json, capabilities/ and etc in the src_tauri_dir directory.

__all__ module-attribute

__all__ = ['builder_factory', 'context_factory']

builder_factory

builder_factory() -> Builder

A factory function for creating a pytauri.Builder instance.

This is a type-hinted wrapper function for pytauri.builder_factory.

Source code in python/pytauri-wheel/python/pytauri_wheel/lib.py
def builder_factory() -> Builder:
    """A factory function for creating a [pytauri.Builder][] instance.

    This is a type-hinted wrapper function for [pytauri.builder_factory][].
    """
    return pytauri_builder_factory()

context_factory

context_factory(src_tauri_dir: Path, /, *, tauri_config: Optional[_PySerdeFrom[_ConfigFrom]] = None) -> Context

Generate a Context based on tauri.conf.json, capabilities/ and etc in the src_tauri_dir directory.

This type-hinted wrapper function for pytauri.context_factory.

Parameters:

Name Type Description Default

src_tauri_dir

Path

The absolute path of the pytauri project directory. In a typical Tauri project, it exists as the src-tauri directory; in the pytauri-wheel project, you only need to provide a similar file layout to src-tauri:

src-tauri/
    __init__.py
    tauri.conf.json
    capabilities/
    ...

required

tauri_config

Optional[_PySerdeFrom[_ConfigFrom]]

The config to be merged with tauri.conf.json, equivalent to the --config of tauri-cli. See: https://tauri.app/develop/configuration-files/#extending-the-configuration.

If str or bytes is provided, it will be deserialized into a JSON object.

tauri_config = {
    "build": {
        "frontendDist": "http://localhost:1420",
    },
}

# Or

tauri_config = json.dumps(
    {
        "build": {
            "frontendDist": "http://localhost:1420",
        },
    }
)
None
Source code in python/pytauri-wheel/python/pytauri_wheel/lib.py
def context_factory(
    src_tauri_dir: Path,
    /,
    *,
    tauri_config: Optional[_PySerdeFrom[_ConfigFrom]] = None,
) -> Context:
    """Generate a `Context` based on `tauri.conf.json`, `capabilities/` and etc in the `src_tauri_dir` directory.

    This type-hinted wrapper function for [pytauri.context_factory][].

    Args:
        src_tauri_dir: The **absolute** path of the pytauri project directory.
            In a typical Tauri project, it exists as the `src-tauri` directory;
            in the `pytauri-wheel` project, you only need to provide a similar file layout to `src-tauri`:
                ```text
                src-tauri/
                    __init__.py
                    tauri.conf.json
                    capabilities/
                    ...
                ```
        tauri_config: The config to be merged with `tauri.conf.json`, equivalent to the `--config` of `tauri-cli`.
            See: <https://tauri.app/develop/configuration-files/#extending-the-configuration>.

            If `str` or `bytes` is provided, it will be deserialized into a JSON object.

            ```python
            tauri_config = {
                "build": {
                    "frontendDist": "http://localhost:1420",
                },
            }

            # Or

            tauri_config = json.dumps(
                {
                    "build": {
                        "frontendDist": "http://localhost:1420",
                    },
                }
            )
            ```
    """
    if not src_tauri_dir.is_absolute():
        raise ValueError("`src_tauri_dir` must be an absolute path.")

    return pytauri_context_factory(src_tauri_dir, tauri_config=tauri_config)