-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_modeller.sh
More file actions
74 lines (56 loc) · 2.06 KB
/
Copy pathsetup_modeller.sh
File metadata and controls
74 lines (56 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# 1. Ensure a Conda environment is actively running
if [ -z "$CONDA_PREFIX" ]; then
echo "❌ Error: No active Conda environment detected!"
echo "Please activate your environment first (e.g., conda activate modcrelib_env)"
exit 1
fi
# 2. Dynamically extract the environment root and the Python version
TOPDIR="$CONDA_PREFIX"
PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
# 3. Establish the standardized Modeller directory structure
TARGET_DIR="${TOPDIR}/lib/modeller-10.8/bin"
mkdir -p "$TARGET_DIR"
echo "⚙️ Configuring environment pathways..."
echo " - Conda Root: $TOPDIR"
echo " - Python Target: $PYTHON_VERSION"
echo " - Output Path: $TARGET_DIR/modpy.sh"
# 4. Generate the modpy.sh script injection block
cat << EOF > "$TARGET_DIR/modpy.sh"
#!/bin/sh
# 1. Force the dynamic script to utilize your Conda environment root
TOPDIR="${TOPDIR}"
# 2. Tell the script where the compiled C-libraries (.dylib files) live in Conda
LLP="\${TOPDIR}/lib"
if test -z "\${LD_LIBRARY_PATH}"; then
LD_LIBRARY_PATH=\${LLP}
else
LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:\${LLP}
fi
if test -z "\${DYLD_LIBRARY_PATH}"; then
DYLD_LIBRARY_PATH=\${LLP}
else
DYLD_LIBRARY_PATH=\${DYLD_LIBRARY_PATH}:\${LLP}
fi
if test -z "\${LIBPATH}"; then
LIBPATH=\${LLP}
else
LIBPATH=\${LIBPATH}:\${LLP}
fi
# 3. Direct Python to where Conda unpacked MODELLER's Python modules.
PP="\${TOPDIR}/lib/python${PYTHON_VERSION}/site-packages"
if test -z "\${PYTHONPATH}"; then
PYTHONPATH=\${PP}
else
ORIGPYPATH="\${PYTHONPATH}"
PYTHONPATH=\${PYTHONPATH}:\${PP}
fi
export LD_LIBRARY_PATH DYLD_LIBRARY_PATH PYTHONPATH LIBPATH ORIGPYPATH
# 4. Drop the redundant 'python' argument passed by the master program
shift
# 5. Force execution through Rosetta 2 using the Conda Intel Python binary
exec arch -x86_64 "\${TOPDIR}/bin/python" "\$@"
EOF
# 5. Unlock executable permissions flags on the newly created script
chmod +x "$TARGET_DIR/modpy.sh"
echo "✅ Generation Complete! modpy.sh is successfully deployed and ready for use."