-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathposix.sh
55 lines (46 loc) · 1.58 KB
/
posix.sh
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
#!/bin/bash
# author: Chen Zhang
# usage:
# * compiling for python 3.9 | 3.10 | 3.11 | 3.12 with documents embedded
# shell> bash posix.sh
# * compiling for python 3.10 | 3.11 without documents embedded
# shell> bash posix.sh '310 311' false
envs="39 310 311 312"
add_doc=$([ "$#" == 0 ] && echo "true" || echo "${2}")
root="$(pwd .)"
dist_dir="${root}/dist"
doc_dir="${root}/docs"
if [[ $(uname) == 'Linux' ]]; then target='Linux_x86_64.whl'; else target='macosx_10_9_x86_64'; fi
if [[ $(uname) == 'Linux' ]]; then prefix="/home/chen"; esle prefix="/Users/chen_zhang"; fi
function single_compiler() {
conda activate "py${1}"
echo "Compiling in environment:"
python --version
if pip list | grep informatics; then pip uninstall informatics --yes; fi
if ! (${2}); then cd "${doc_dir}" || exit; make clean; cd "${root}" || exit; fi
python -m build -w -Cbuild_ext
if (${2})
then
cd "${dist_dir}" || exit
whl=$(find . -maxdepth 1 | grep "$target" | grep "cp${1}")
if (($(echo "${whl}" | wc -l) == 1)); then pip install "${whl}"; fi
cd "${doc_dir}" || exit
make clean && make html
cd "${root}" || exit
python -m build -w -Cbuild_ext
pip uninstall informatics --yes
fi
conda deactivate
}
function batch_compiler() {
source "${prefix}"/anaconda3/etc/profile.d/conda.sh
single_compiler "${1}" "${2}"
cd "${root}" || exit
}
environments=$([ "$#" == 0 ] && echo "$envs" || echo "${1}")
IFS=' '
read -ra arr <<< "$environments"
for var in "${arr[@]}";
do
batch_compiler "$var" "$add_doc" "$root"
done