forked from libsemigroups/libsemigroups_pybind11
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-dev-environment.sh
More file actions
executable file
·85 lines (74 loc) · 2.4 KB
/
make-dev-environment.sh
File metadata and controls
executable file
·85 lines (74 loc) · 2.4 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
#!/bin/bash
is_sourced() {
if [ -n "$ZSH_VERSION" ]; then
case $ZSH_EVAL_CONTEXT in *:file:*) return 0 ;; esac
else
case ${0##*/} in dash | -dash | bash | -bash | ksh | -ksh | sh | -sh) return 0 ;; esac
fi
return 1 # NOT sourced.
}
is_sourced && sourced=1 || sourced=0
if [[ $sourced -ne 1 ]]; then
echo This script must be sourced, rather than run directly. Please try again with:
echo source $(basename "$0")
exit
fi
unset sourced
if [[ $# -eq 0 ]]; then
dev_env_pkg_manager=mamba
else
dev_env_pkg_manager=$1
fi
if { $dev_env_pkg_manager env list | grep 'libsemigroups_pybind11_dev'; } >/dev/null 2>&1; then
echo The environment libsemigroups_pybind11_dev already exists. Stopping ...
unset dev_env_pkg_manager
return
else
echo Making libsemigroups_pybind11_dev environment using $dev_env_pkg_manager ...
echo
$dev_env_pkg_manager env create -f dev-environment.yml
if [[ $? -ne 0 ]]; then
echo The environment was not successfully created. Stopping ...
unset dev_env_pkg_manager
return
fi
echo Activating libsemigroups_pybind11_dev ...
echo
$dev_env_pkg_manager activate libsemigroups_pybind11_dev
if [[ $? -ne 0 ]]; then
echo The environment cannot be activated. Please try activating it yourself, and then
echo run the set-conda-environment-variables.sh script to set the environment variables
unset dev_env_pkg_manager
return
fi
fi
echo Setting environment variables ...
echo
# Use conda for environment variable setup if both mamba and conda are available
# as mamba and conda CLIs are no longer equivalent for this operation
env_var_pkg_manager=$dev_env_pkg_manager
if [[ $dev_env_pkg_manager == "mamba" ]] && command -v conda >/dev/null 2>&1; then
echo "Using conda for environment variable setup (mamba CLI not compatible) ..."
env_var_pkg_manager=conda
fi
./etc/set-conda-environment-variables.sh -m $env_var_pkg_manager
unset env_var_pkg_manager
echo
echo Reactivating environment ...
echo
$dev_env_pkg_manager deactivate
if [[ $? -ne 0 ]]; then
unset dev_env_pkg_manager
return
fi
$dev_env_pkg_manager activate libsemigroups_pybind11_dev
if [[ $? -ne 0 ]]; then
unset dev_env_pkg_manager
return
fi
echo
echo Checking environment variables ...
echo
echo LD_LIBRARY_PATH: $LD_LIBRARY_PATH
echo PKG_CONFIG_PATH: $PKG_CONFIG_PATH
unset dev_env_pkg_manager