Getting Started

This guide will help you get started with Appose in your preferred programming language.

Installation

PyPI/Pip

Add appose to your project dependencies in pyproject.toml:

dependencies = [
  "appose"
]

Or install directly:

pip install appose

Conda/Mamba

Add appose to your environment.yml:

dependencies:
  - appose

Or install directly:

conda install -c conda-forge appose

Prerequisites

To use Appose from Python, you need:

  • Python 3.10 or higher

  • Java 8+ (if calling Java/Groovy workers)

Your First Appose Program

Let’s create a simple program that demonstrates Appose’s basic functionality.

Create a file hello_appose.py:

import appose

# Create an environment using the system Java
env = appose.system()

# Launch a Groovy worker service
with env.groovy() as groovy:
    # Execute a simple calculation
    task = groovy.task("5 + 6")
    task.wait_for()

    # Get the result
    result = task.result()
    print(f"Result: {result}")
    # Output: Result: 11

Run it:

python hello_appose.py

Understanding the Code

Let’s break down what’s happening:

  1. Environment Creation: Appose.system() (Java) or appose.system() (Python) creates an environment that uses the system’s installed executables.

  2. Service Creation: env.python() or env.groovy() launches a worker process in the target language.

  3. Task Execution: service.task(script) sends a script to the worker for asynchronous execution.

  4. Waiting for Results: task.waitFor() or task.wait_for() blocks until the task completes.

  5. Getting Results: Task outputs are available in the outputs map/dictionary.

Next Steps

Now that you have Appose running, you can:

Building Custom Environments

Instead of using the system environment, you can build isolated environments with specific dependencies.

Using Pixi (recommended):

env = appose.pixi() \
    .conda("python>=3.10", "numpy", "pandas") \
    .pypi("scikit-learn") \
    .channels("conda-forge") \
    .name("my-ml-env") \
    .build()

Using Conda/Mamba:

env = appose.mamba("environment.yml").build()

Using uv (Python virtual environments):

env = appose.uv() \
    .python("3.11") \
    .include("numpy", "pandas", "matplotlib") \
    .name("my-env") \
    .build()

Environments are cached by default in ~/.local/share/appose/<env-name>, so they only need to be built once.