OpenParable
Skip to content
← Back to skills

Link Pymllm Lib

Development
link-pymllm-lib

Link Pymllm Lib is an Agent Skill for development published in the UbiquitousLearning/mllm repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Create or update the pymllm/lib symlink to point to a C++ build directory's bin/ folder. Required after editable installs with C++ builds so that Python can find the compiled .so libraries. Use when the user asks to link, fix, or set up pymllm native libraries.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/UbiquitousLearning/mllm/blob/HEAD/.claude/skills/link-pymllm-lib/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/link-pymllm-lib, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Link pymllm lib

Goal

Create a symlink at pymllm/lib pointing to the correct build output directory so that an editable-installed pymllm can load the compiled C++ shared libraries (MllmFFIExtension.so, libMllmRT.so, etc.).

Background

When pymllm is installed in editable mode (pip install -e .), Python imports from the source tree directly. The C++ libraries are compiled into <build-dir>/bin/ by CMake, but pymllm looks for them at pymllm/lib/. A symlink bridges this gap:

pymllm/lib -> <project-root>/<build-dir>/bin

Workflow

Step 1: Detect available build directories

Scan the project root for directories matching the pattern build*/bin/ that contain MllmFFIExtension.so (or .dylib on macOS). List all valid candidates.

Common build directories and their corresponding platforms:

Build directoryPlatform / ConfigTypical build command
build/binX86 CPU onlypython task.py tasks/build_x86.yaml
build-x86-cuda/binX86 + CUDApython task.py tasks/build_x86_cuda.yaml
build-qnn-aot/binX86 + QNN AOTpython task.py tasks/build_x86_qnn_aot.yaml
build-android-arm64-v8a-qnn/binAndroid ARM + QNNpython task.py tasks/build_android_qnn.yaml

Step 2: Ask the user which build to link

Use AskUserQuestion to let the user pick from the detected build directories. Show each option with its path and the platform it corresponds to.

If no build directories with .so files are found, inform the user they need to build first:

pip install -r requirements.txt
python task.py tasks/build_x86.yaml  # or another build task

Step 3: Check existing symlink

Before creating a new symlink, check if pymllm/lib already exists:

  • If it's a symlink, show where it currently points and confirm replacement.
  • If it's a real directory, warn the user and ask before removing it.
  • If it doesn't exist, proceed directly.

Step 4: Create the symlink

ln -sfn <project-root>/<build-dir>/bin <project-root>/pymllm/lib

Use ln -sfn to atomically replace any existing symlink.

Step 5: Verify

After creating the symlink, verify by checking that the target .so file is accessible:

ls -la pymllm/lib/MllmFFIExtension.so

Then run a quick Python check:

python -c "import pymllm; print('mobile available:', pymllm.is_mobile_available())"

If is_mobile_available() returns True, the link is correct.

Important Notes

  • The symlink target must be an absolute path for reliability.
  • On macOS, the library extension is .dylib instead of .so.
  • Android build directories (e.g., build-android-arm64-v8a-qnn/bin) contain ARM binaries that cannot run on x86 hosts. Warn the user if they select one of these on a non-ARM machine.
  • If the user has multiple build directories, they can re-run this skill anytime to switch which build pymllm uses.