forked from project-codeflare/zero-copy-model-loading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.sh
executable file
·135 lines (112 loc) · 3.76 KB
/
env.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
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
#! /bin/bash
# Create conda environment to run the notebooks in this directory.
#
# By default, the environment will be located in the directory "env"
# immediately under this one. To override that setting,
# pass the subdirectory name as the first argument to this script, i.e.
#
# $ ./env.sh my_dir_name
PYTHON_VERSION=3.8
############################
# HACK ALERT *** HACK ALERT
# The friendly folks at Anaconda thought it would be a good idea to make the
# "conda" command a shell function.
# See https://github.com/conda/conda/issues/7126
# The following workaround will probably be fragile.
if [ -z "$CONDA_HOME" ]
then
echo "Error: CONDA_HOME not set."
exit
fi
if [ -e "${CONDA_HOME}/etc/profile.d/conda.sh" ]
then
# shellcheck disable=SC1090
. "${CONDA_HOME}/etc/profile.d/conda.sh"
else
echo "Error: CONDA_HOME (${CONDA_HOME}) does not appear to be set up."
exit
fi
# END HACK
############################
Usage()
{
echo "Usage ./env.sh [-d dir_name] [-p] [-h]"
echo "Where:"
echo " -d dir_name specifies the location of the environment."
echo " (default is ./env)"
echo " -p means to install the zerocopy module from PyPI"
echo " (default is to install from local source)"
echo " -h prints this message"
}
INSTALL_FROM_PYPI=false
ENV_DIR="env"
while getopts ":hpd:" option; do
case $option in
h) # display Help
Usage
exit;;
d) # Specify directory
ENV_DIR=$OPTARG;;
p) # Install from PyPI
INSTALL_FROM_PYPI=true;;
\?) # Invalid option
Usage
exit;;
esac
done
echo "Creating an Anaconda environment at ./${ENV_DIR}"
if [ "$INSTALL_FROM_PYPI" = true ] ; then
echo "Will install zerocopy package from PyPI"
else
echo "Will install zerocopy package from local source tree"
fi
# Remove the detritus of any previous runs of this script
rm -rf ./${ENV_DIR}
# Note how we explicitly install pip on the line that follows. THIS IS VERY
# IMPORTANT!
conda create -y -p ${ENV_DIR} python=${PYTHON_VERSION} pip
conda activate ./${ENV_DIR}
################################################################################
# Install packages with conda
# We currently install JupyterLab from conda because the pip packages are
# broken for Anaconda environments with Python 3.6 and 3.8 on Mac, as of
# April 2022.
# Make sure that we install everything so that some pip dependency doesn't
# pull in incompatible PyPI versions of a Jupyter package.
conda install -y -c conda-forge jupyterlab \
ipywidgets \
jupyterlab-git \
jupyter-lsp \
jupyterlab-lsp \
jupyter-packaging \
jupyter-resource-usage
conda install -y -c conda-forge/label/main nodejs
# Rebuild local JupyterLab resources, because sometimes the conda-forge
# packages don't come properly configured.
jupyter lab build
################################################################################
# Install packages with pip
# Pip dependencies are all in requirements.txt
pip install -r requirements.txt
if [ "$INSTALL_FROM_PYPI" = true ] ; then
pip install zerocopy
else
# Install the local source tree for the `zerocopy` package in editable mode
pip install --editable ./package
fi
################################################################################
# Custom install steps
# Elyra extensions to JupyterLab (enables git integration, debugger, workflow
# editor, outlines, and other features)
pip install --upgrade --use-deprecated=legacy-resolver elyra
# Rebuild JupyterLab environment
jupyter lab build
jupyter --version
echo " "
jupyter serverextension list
echo " "
jupyter labextension list
echo " "
conda deactivate
echo "Anaconda environment at ./${ENV_DIR} successfully created."
echo "To use, type 'conda activate ./${ENV_DIR}'."