mjlab/scripts/fix_mjpython_macos.sh
Upstream Snapshot 32a241c28f
Some checks failed
nightly / Test against latest dependencies (py3.10) (push) Has been cancelled
nightly / Test against latest dependencies (py3.13) (push) Has been cancelled
tests / tests (3.13, locked) (push) Has been cancelled
tests / tests (3.13, unlocked) (push) Has been cancelled
tests / pyright (3.10) (push) Has been cancelled
tests / lint-format (push) Has been cancelled
tests / tests (3.10, locked) (push) Has been cancelled
tests / tests (3.11, locked) (push) Has been cancelled
tests / tests (3.12, locked) (push) Has been cancelled
tests / pyright (3.11) (push) Has been cancelled
tests / pyright (3.12) (push) Has been cancelled
tests / pyright (3.13) (push) Has been cancelled
tests / ty-check (3.10) (push) Has been cancelled
tests / ty-check (3.11) (push) Has been cancelled
tests / ty-check (3.12) (push) Has been cancelled
tests / ty-check (3.13) (push) Has been cancelled
tests / stubs (push) Has been cancelled
tests / smoke-test (push) Has been cancelled
Docker / check_paths (push) Has been cancelled
docs / build (push) Has been cancelled
Docker / build (push) Has been cancelled
Import upstream snapshot c19f713c415a699a79d71cd96aa13c3104a05047
Upstream: https://github.com/michaelgillett/mjlab
Upstream-Commit: c19f713c415a699a79d71cd96aa13c3104a05047
Upstream-Branch: main
2026-08-28 15:42:17 +08:00

37 lines
1017 B
Bash

#!/bin/bash
# Fix mjpython on macOS by creating a symlink to libpython.
# This is needed because mjpython expects libpython in .venv/lib/
set -e
VENV_DIR=".venv"
if [[ "$(uname)" != "Darwin" ]]; then
echo "This script is only needed on macOS."
exit 0
fi
if [[ ! -d "$VENV_DIR" ]]; then
echo "Error: .venv directory not found. Run 'uv sync' first."
exit 1
fi
# Get Python version and prefix from the venv.
PYTHON_VERSION=$("$VENV_DIR/bin/python" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PYTHON_PREFIX=$("$VENV_DIR/bin/python" -c "import sys; print(sys.base_prefix)")
DYLIB_NAME="libpython${PYTHON_VERSION}.dylib"
# Find the dylib in the Python installation.
DYLIB_PATH="$PYTHON_PREFIX/lib/$DYLIB_NAME"
if [[ ! -f "$DYLIB_PATH" ]]; then
echo "Error: Could not find $DYLIB_PATH"
exit 1
fi
# Create the symlink.
mkdir -p "$VENV_DIR/lib"
ln -sf "$DYLIB_PATH" "$VENV_DIR/lib/$DYLIB_NAME"
echo "Created symlink: $VENV_DIR/lib/$DYLIB_NAME -> $DYLIB_PATH"