> ## Documentation Index
> Fetch the complete documentation index at: https://docs.muna.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# muna transpile

> Transpile a Python function to C++ source code.

The `transpile` command converts a Python function into C++ source code. You can then
compile the generated source code into a library or executable:

<video autoPlay muted loop playsInline className="w-full aspect-video rounded-xl" src="https://mintcdn.com/natml/c0_zhoe1s86cQ2qQ/videos/transpile.mp4?fit=max&auto=format&n=c0_zhoe1s86cQ2qQ&q=85&s=d1ed5bf7e7e4e558c44cde7d301b5f43" data-path="videos/transpile.mp4" />

## Usage

```bash icon="terminal" theme={null}
# Transpile a Python function
$ muna transpile [OPTIONS] PATH
```

The provided `path` can either be a path to a Python module; or a URL pointing to a Python module. There must be a function decorated with [`@compile`](/predictors/create).

### Specifying the Output Directory

Use the `--output` flag to write the generated sources to a given directory:

```bash icon="terminal" theme={null}
# Output to a custom directory
$ muna transpile  --output ./generated greeting.py
```

<Note>
  The provided directory must not already exist on the file system.
</Note>

### Transpiling from GitHub

You can transpile Python files directly from GitHub:

```bash icon="terminal" theme={null}
# Transpile from a GitHub URL
$ muna transpile --trust-remote-code https://github.com/muna-ai/muna-predictors/blob/main/python-coverage/fstring.py
```

<Warning>
  When using `--trust-remote-code`, the CLI will download and execute code from the remote URL. Only use this option with code sources you trust.
</Warning>

## Using the Generated Code

The generated code defines a header which can be used in C++ libraries and applications;
along with an example command-line application that runs the compiled function.

The `muna transpile` command will write a self-contained header file (`*.hpp`) along
with a `CMakeLists.txt` file to the output directory.

### Running the Example Code

Build the example application using `cmake`:

```sh icon="terminal" theme={null}
# 🔥 Build the example application
$ cmake -B build && cmake --build build
```

<Note>
  Building the example application requires `cmake` to be installed, along with a
  compiler toolchain for the current system (e.g. Visual Studio, Xcode, etc).
</Note>

Once compiled, you can then run the example app in the command line:

```sh icon="terminal" theme={null}
# 🚀 Run the example app
$ ./example --help
```

### Using the Library

You can also use the transpiled function as a library in a C++ target:

```cmake CMakeLists.txt theme={null}
# Include the transpiled function
include(generated)

# Link against the transpiled function
target_link_libraries(
    my_app PRIVATE
    greeting::greeting
)
```

<Tip>
  For most use cases, you should use [`muna compile`](/cli/compile) instead, which handles
  transpilation, compilation, and deployment in a single step.
</Tip>
