FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
HydroModPy/install/enter_wsl_dev.sh at dev · HydroModPy/HydroModPy · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
HydroModPy
/
HydroModPy
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
11
Code
Issues
18
Pull requests
1
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
HydroModPy
/
install
/
enter_wsl_dev.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
182 lines (156 loc) · 4.26 KB
Breadcrumbs
HydroModPy
/
install
/
enter_wsl_dev.sh
Copy path
File metadata and controls
182 lines (156 loc) · 4.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!
/usr/bin/env bash
set
-euo pipefail
usage
() {
cat
<<
'
EOF
'
Usage: bash install/enter_wsl_dev.sh [options] [-- command...]
Open one ready-to-use HydroModPy WSL shell, or run one command inside it.
Options:
--env-name NAME Conda environment name (default: hydromodpy-wsl)
--headless Export MPLBACKEND=Agg for non-interactive matplotlib
--with-display Unset MPLBACKEND
--output-root PATH Export HYDROMODPY_OUT_PATH to the given path
-h, --help Show this help and exit
Examples:
bash install/enter_wsl_dev.sh
bash install/enter_wsl_dev.sh --headless
bash install/enter_wsl_dev.sh --output-root /mnt/c/Users/dreuzy/Documents/HydroModPyOutputs
bash install/enter_wsl_dev.sh -- python -m pytest tests/unit/simulation/test_boussinesq_flow_adapter.py -q
EOF
}
ENV_NAME=
"
hydromodpy-wsl
"
HEADLESS_MODE=
"
keep
"
OUTPUT_ROOT=
"
"
while
[[
$#
-gt
0 ]]
;
do
case
"
$1
"
in
--env-name)
ENV_NAME=
"
$2
"
shift
2
;;
--headless)
HEADLESS_MODE=
"
on
"
shift
;;
--with-display)
HEADLESS_MODE=
"
off
"
shift
;;
--output-root)
OUTPUT_ROOT=
"
$2
"
shift
2
;;
--)
shift
break
;;
-h|--help)
usage
exit
0
;;
*
)
break
;;
esac
done
SCRIPT_DIR=
"
$(
cd --
"
$(
dirname --
"
${BASH_SOURCE[0]}
"
)
"
&&
pwd
)
"
REPO_ROOT=
"
$(
cd --
"
${SCRIPT_DIR}
/..
"
&&
pwd
)
"
resolve_env_target
() {
local
env_name=
"
$1
"
if
conda env list
2>
/dev/null
|
awk
'
{print $1}
'
|
grep -Fxq
"
${env_name}
"
;
then
printf
'
%s\n
'
"
${env_name}
"
return
0
fi
local
candidates=(
"
${HOME}
/miniforge3/envs/
${env_name}
"
"
${HOME}
/mambaforge/envs/
${env_name}
"
"
${HOME}
/miniconda3/envs/
${env_name}
"
"
${HOME}
/anaconda3/envs/
${env_name}
"
)
local
candidate=
"
"
for
candidate
in
"
${candidates[@]}
"
;
do
if
[[
-d
"
${candidate}
"
]]
;
then
printf
'
%s\n
'
"
${candidate}
"
return
0
fi
done
return
1
}
load_conda
() {
if
command
-v conda
>
/dev/null
2>&1
;
then
if
[[
"
$(
type -t conda
||
true
)
"
==
"
function
"
]]
;
then
return
0
fi
local
conda_base=
"
"
if
conda_base=
"
$(
conda info --base
2>
/dev/null
)
"
;
then
if
[[
-f
"
${conda_base}
/etc/profile.d/conda.sh
"
]]
;
then
#
shellcheck disable=SC1090
source
"
${conda_base}
/etc/profile.d/conda.sh
"
if
[[
"
$(
type -t conda
||
true
)
"
==
"
function
"
]]
;
then
return
0
fi
fi
fi
if
eval
"
$(
conda shell.bash hook
2>
/dev/null
)
"
;
then
if
[[
"
$(
type -t conda
||
true
)
"
==
"
function
"
]]
;
then
return
0
fi
fi
fi
local
candidates=(
"
${HOME}
/miniforge3/etc/profile.d/conda.sh
"
"
${HOME}
/mambaforge/etc/profile.d/conda.sh
"
"
${HOME}
/anaconda3/etc/profile.d/conda.sh
"
"
${HOME}
/miniconda3/etc/profile.d/conda.sh
"
)
local
candidate=
"
"
for
candidate
in
"
${candidates[@]}
"
;
do
if
[[
-f
"
${candidate}
"
]]
;
then
#
shellcheck disable=SC1090
source
"
${candidate}
"
return
0
fi
done
echo
"
conda could not be found in this WSL shell.
"
>&2
echo
"
Run: bash install/setup_wsl_dev.sh --env-name
${ENV_NAME}
--with-petsc
"
>&2
exit
1
}
load_conda
if
!
ENV_TARGET=
"
$(
resolve_env_target
"
${ENV_NAME}
"
)
"
;
then
echo
"
Could not find Conda environment '
${ENV_NAME}
'.
"
>&2
echo
"
Known locations checked: ~/miniforge3/envs, ~/mambaforge/envs, ~/miniconda3/envs, ~/anaconda3/envs
"
>&2
echo
"
If needed, create it once with:
"
>&2
echo
"
bash install/setup_wsl_dev.sh --env-name
${ENV_NAME}
--with-petsc
"
>&2
exit
1
fi
conda activate
"
${ENV_TARGET}
"
cd
"
${REPO_ROOT}
"
case
"
${HEADLESS_MODE}
"
in
on)
export
MPLBACKEND=Agg
;;
off)
unset
MPLBACKEND
||
true
;;
esac
if
[[
-n
"
${OUTPUT_ROOT}
"
]]
;
then
export
HYDROMODPY_OUT_PATH=
"
${OUTPUT_ROOT}
"
fi
echo
"
HydroModPy WSL session ready
"
echo
"
repo:
${REPO_ROOT}
"
echo
"
env:
${ENV_TARGET}
"
if
[[
-n
"
${OUTPUT_ROOT}
"
]]
;
then
echo
"
out:
${HYDROMODPY_OUT_PATH}
"
fi
exec_hmp_or_command
() {
case
"
${1
:-
}
"
in
add|best|compare|completion|config|data|delete|display|doctor|export|import|init|inspect|install-binaries|lock|manage|new|report|run|schema|show|test|worst|-V|--version)
exec
python -m hydromodpy
"
$@
"
;;
*
)
exec
"
$@
"
;;
esac
}
if
[[
$#
-gt
0 ]]
;
then
exec_hmp_or_command
"
$@
"
fi
exec
"
${SHELL
:-/
bin
/
bash}
"
-i
Back
|
FazBrowse Home
|
New Git URL