-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjopt-docker-entrypoint.sh
More file actions
55 lines (45 loc) · 1.83 KB
/
Copy pathjopt-docker-entrypoint.sh
File metadata and controls
55 lines (45 loc) · 1.83 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
#!/bin/sh
set -eu
echo "Trying to download Python-REST-Client-Examples"
folder="/home/coder/project/python.rest.examples/"
url="https://github.com/DNA-Evolutions/Python-REST-Client-Examples.git"
# Clone the repository if the folder does not exist
if [ ! -d "${folder}" ]; then
echo "Cloning repository from ${url} to ${folder}"
git clone "${url}" "${folder}"
else
echo "Clone skipped as the folder ${folder} already exists. If you want a 'fresh' clone, choose another volume or rename the existing folder."
fi
# Ensure project directory is in the Python path
export PYTHONPATH=${PYTHONPATH:-""}:${folder}
# Activate the virtual environment
. /opt/venv/bin/activate
# Check if installation is needed and install if necessary
if [ -d "${folder}" ]; then
cd "${folder}"
if [ ! -f ".installed" ]; then
echo "Running pip install -e . in ${folder}"
if pip install -e .; then
echo "Installation completed successfully."
touch .installed
else
echo "Installation failed."
fi
else
echo "Installation skipped as it appears to be already done."
fi
else
echo "Folder ${folder} does not exist. Skipping installation."
fi
# Ensure .vscode directory exists within the project folder
mkdir -p ${folder}.vscode
# Ensure VS Code uses the virtual environment's interpreter and Jupyter kernel
echo "{
\"python.defaultInterpreterPath\": \"/opt/venv/bin/python3\",
\"python.terminal.activateEnvironment\": true,
\"jupyter.kernels.filter\": [],
\"notebook.kernelPicker.type\": \"mru\"
}" > ${folder}.vscode/settings.json
# Re-register Jupyter kernel with the project in PYTHONPATH so notebook imports work
/opt/venv/bin/python -m ipykernel install --user --name=jopt-venv --display-name="Python (JOpt)" --env PYTHONPATH "${folder}"
exec /usr/bin/entrypoint.sh "$@"