#!/bin/bash echo "Loading Bernina Python (pixi)" # <<< conda initialize <<< # Prefer the local per-host pixi mirror in ~/bpy (see pixi_local_sync) # over the shared NFS install, for speed -- but only once verified # identical: pixi.lock fully determines what gets built (see chat), so a # byte-for-byte match against the shared lock means the local bpy312 is # guaranteed the same as the shared activation below. # Anything else (no local copy yet, a sync in progress, or behind) falls # back to the existing shared-NFS activation, unchanged. # # The lock match alone isn't enough though: pixi_local_sync copies # pixi.lock BEFORE it finishes (re)installing bpy312/bin, so there's a # window where the lock already matches but the env on disk is still # being rewritten. Guard against that with a non-blocking SHARED flock # on the same lock file that script holds EXCLUSIVELY during that whole # window -- if we can't get it, a sync is actively running right now, so # fall back rather than risk activating a half-linked env. _bpy_pixi=/usr/bin/pixi # console (system) pixi first [ -x "$_bpy_pixi" ] || _bpy_pixi=/sf/bernina/bin/pixi # fallback, e.g. on ra (RHEL8) _bpy_local="$HOME/bpy" _bpy_activated=0 if [ -d "$_bpy_local/.pixi_local_sync" ]; then exec 8>"$_bpy_local/.pixi_local_sync/.install.lock" if flock -s -n 8; then if cmp -s "$_bpy_local/pixi.lock" /sf/bernina/applications/python/pixi.lock 2>/dev/null \ && [ -d "$_bpy_local/.pixi/envs/bpy312/bin" ]; then eval "$("$_bpy_pixi" shell-hook -e bpy312 -s bash -m "$_bpy_local/pixi.toml")" _bpy_activated=1 fi flock -u 8 fi exec 8>&- fi # Shared env: --as-is never installs or relocks (users can't write there). [ "$_bpy_activated" -eq 1 ] || eval "$("$_bpy_pixi" shell-hook --as-is -e bpy312 -s bash \ --manifest-path /sf/bernina/applications/python/pixi.toml)" unset _bpy_pixi _bpy_local _bpy_activated micromamba config append envs_dirs /sf/bernina/applications/python/environments