-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.fish
More file actions
120 lines (104 loc) · 3.49 KB
/
activate.fish
File metadata and controls
120 lines (104 loc) · 3.49 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env fish
# Fish shell activation script
# Usage: source activate.fish
# Get the directory containing this script (absolute, without changing PWD)
set SCRIPT_DIR (dirname (status --current-filename))
if type -q path
set -gx CODE (path resolve $SCRIPT_DIR)
else if type -q realpath
set -gx CODE (realpath $SCRIPT_DIR)
else
# Fallback: temporarily cd and restore
set -l __oldpwd $PWD
cd $SCRIPT_DIR
set -gx CODE $PWD
cd $__oldpwd
end
echo "Setting CODE environment to: $CODE"
# Check if the OS is macOS
if test (uname) = "Darwin"
echo "Running on macOS"
# Check the processor type
if test (uname -m) = "arm64"
echo "This is an Apple Silicon Mac."
set -gx BLAS_LIBRARIES /opt/homebrew/opt/openblas/lib/libopenblas.dylib
set -gx LAPACK_LIBRARIES /opt/homebrew/opt/openblas/lib/liblapack.dylib
else if test (uname -m) = "x86_64"
echo "This is an Intel Mac."
set -gx BLAS_LIBRARIES /usr/local/opt/openblas/lib/libopenblas.dylib
set -gx LAPACK_LIBRARIES /usr/local/opt/openblas/lib/liblapack.dylib
else
echo "Unknown processor architecture."
end
set -gx CMAKE_INCLUDE_PATH "/opt/homebrew/include/suitesparse:$CODE/external/triangle"
set -gx CMAKE_LIBRARY_PATH "/opt/homebrew/lib:$CODE/external/triangle/build"
set -gx CMAKE_ARGS "-DBLAS_LIBRARIES=$BLAS_LIBRARIES -DLAPACK_LIBRARIES=$LAPACK_LIBRARIES"
else
set -gx CMAKE_ARGS ""
end
# Fish-specific utility functions
function add_to_path_fish
set dir $argv[1]
if test -d "$dir"
if not contains "$dir" $PATH
set -gx PATH $dir $PATH
end
end
end
function add_to_library_path_fish
set dir $argv[1]
if test -d "$dir"
if not contains "$dir" $LD_LIBRARY_PATH
set -gx LD_LIBRARY_PATH $dir $LD_LIBRARY_PATH
end
end
if test (uname) = "Darwin"
if test -d "$dir"
if not contains "$dir" $DYLD_LIBRARY_PATH
set -gx DYLD_LIBRARY_PATH $dir $DYLD_LIBRARY_PATH
end
end
end
end
# Set branch information
function set_branch_fish
if test -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"
set -gx CODE_BRANCH $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
else if test -n "$CI_COMMIT_REF_NAME"
set -gx CODE_BRANCH $CI_COMMIT_REF_NAME
else
# Avoid directory changes; query git directly in $CODE
set -gx CODE_BRANCH (git -C $CODE branch --show-current)
if test -z "$CODE_BRANCH"
set -gx CODE_BRANCH (git -C $CODE rev-parse --short HEAD)
end
end
echo "Activating $CODE on branch $CODE_BRANCH"
end
# Set up paths
set_branch_fish
add_to_path_fish $CODE/scripts
add_to_path_fish $CODE/local/bin
add_to_path_fish $CODE/bin
add_to_library_path_fish $CODE/libneo/build
add_to_library_path_fish $CODE/local/lib
add_to_library_path_fish $CODE/lib
# Activate Python virtual environment
if test -f $CODE/.venv/bin/activate.fish
source $CODE/.venv/bin/activate.fish
else
echo "Warning: Python virtual environment fish activation script not found"
echo "Run: python -m venv $CODE/.venv to create it"
end
# Load modules if available
if test -f /etc/profile.d/modules.sh
# Fish can't directly source shell scripts, but we can try to set up modules
echo "Note: Module system may require manual setup in fish shell"
end
# Create aliases
alias cdcode="cd $CODE"
if command -v code > /dev/null
alias vscode="code $CODE"
end
module use -a $CODE/modules
echo "Fish shell activation complete!"