Skip to content

Commit 266ab2b

Browse files
authored
refactor: dependency installation for Quarto computing features (#14)
1 parent 927b388 commit 266ab2b

File tree

3 files changed

+65
-62
lines changed

3 files changed

+65
-62
lines changed

.github/.devcontainer/devcontainer.json

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,15 @@
1010
},
1111
"remoteUser": "vscode",
1212
"features": {
13-
"ghcr.io/devcontainers/features/common-utils:2": {
14-
"installZsh": "true",
15-
"username": "vscode",
16-
"userUid": "1000",
17-
"userGid": "1000",
18-
"upgradePackages": "true"
19-
},
20-
"ghcr.io/devcontainers/features/git:1": {
21-
"version": "latest",
22-
"ppa": "false"
23-
},
24-
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": {
25-
"version": "release",
26-
"vscodeRSupport": "none",
27-
"installDevTools": "false",
28-
"installREnv": "true",
29-
"installRMarkdown": "false"
30-
},
31-
"ghcr.io/devcontainers/features/python:1": {
32-
"version": "latest",
33-
"enableShared": "true"
34-
},
35-
"ghcr.io/julialang/devcontainer-features/julia:1": {
36-
"channel": "release"
37-
},
3813
"./quarto-computing-dependencies": {
39-
"dependencies": "all"
40-
},
41-
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
42-
"version": "prerelease",
43-
"installTinyTex": "true",
44-
"installChromium": "false"
45-
}
14+
"rDeps": "rmarkdown,httpgd",
15+
"pythonDeps": "jupyter,papermill",
16+
"juliaDeps": "IJulia"
17+
}//,
18+
// "ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
19+
// "version": "prerelease",
20+
// "installTinyTex": "true",
21+
// "installChromium": "false"
22+
// }
4623
}
4724
}

.github/.devcontainer/quarto-computing-dependencies/devcontainer-feature.json

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,52 @@
44
"name": "Install Computing Dependencies for Quarto",
55
"description": "Install R, Python, and Julia dependencies for Quarto.",
66
"options": {
7-
"dependencies": {
7+
"rDeps": {
88
"type": "string",
9-
"enum": ["all", "r", "python", "julia"],
10-
"default": "all",
11-
"description": "Specify what dependencies to install."
12-
}
9+
"default": "rmarkdown",
10+
"description": "Specify what R dependencies to install."
11+
},
12+
"pythonDeps": {
13+
"type": "string",
14+
"default": "jupyter,papermill",
15+
"description": "Specify what Python dependencies to install."
16+
},
17+
"juliaDeps": {
18+
"type": "string",
19+
"default": "IJulia",
20+
"description": "Specify what Julia dependencies to install."
21+
}
1322
},
1423
"dependsOn": {
15-
"ghcr.io/devcontainers/features/common-utils": {},
16-
"ghcr.io/rocker-org/devcontainer-features/r-rig": {},
17-
"ghcr.io/devcontainers/features/python": {},
18-
"ghcr.io/julialang/devcontainer-features/julia": {}
24+
"ghcr.io/devcontainers/features/common-utils:2": {
25+
"installZsh": "true",
26+
"username": "vscode",
27+
"userUid": "1000",
28+
"userGid": "1000",
29+
"upgradePackages": "true"
30+
},
31+
"ghcr.io/devcontainers/features/git:1": {
32+
"version": "latest",
33+
"ppa": "false"
34+
},
35+
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": {
36+
"version": "release",
37+
"vscodeRSupport": "none",
38+
"installDevTools": "false",
39+
"installREnv": "true",
40+
"installRMarkdown": "false"
41+
},
42+
"ghcr.io/devcontainers/features/python:1": {
43+
"version": "latest",
44+
"enableShared": "true"
45+
},
46+
"ghcr.io/julialang/devcontainer-features/julia:1": {
47+
"channel": "release"
48+
}
1949
},
2050
"installsAfter": [
2151
"ghcr.io/devcontainers/features/common-utils",
52+
"ghcr.io/devcontainers/features/git",
2253
"ghcr.io/rocker-org/devcontainer-features/r-rig",
2354
"ghcr.io/devcontainers/features/python",
2455
"ghcr.io/julialang/devcontainer-features/julia"

.github/.devcontainer/quarto-computing-dependencies/install.sh

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ set -e
44

55
export DEBIAN_FRONTEND=noninteractive
66

7-
DEPENDENCIES=${DEPENDENCIES:-"all"}
8-
97
USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}}
108

9+
R_DEPS=${RDEPS:-"rmarkdown"}
10+
PYTHON_DEPS=${PYTHONDEPS:-"jupyter,papermill"}
11+
JULIA_DEPS=${JULIADEPS:-"IJulia"}
12+
1113
set -e
1214

1315
if [ "$(id -u)" -ne 0 ]; then
@@ -33,30 +35,23 @@ elif [ "${USERNAME}" = "none" ] || ! id -u "${USERNAME}" >/dev/null 2>&1; then
3335
fi
3436

3537
quarto_r_deps() {
36-
su "${USERNAME}" -c "Rscript -e 'pak::pkg_install(\"rmarkdown\")'"
38+
local deps=$1
39+
deps=$(echo "${deps}" | sed 's/,/","/g')
40+
su "${USERNAME}" -c "Rscript -e 'pak::pkg_install(c(\"${deps}\"))'"
3741
}
3842

3943
quarto_python_deps() {
40-
su "${USERNAME}" -c "python3 -m pip install jupyter papermill"
44+
local deps=$1
45+
deps=$(echo "${deps}" | sed 's/,/ /g')
46+
python3 -m pip install ${deps}
4147
}
4248

4349
quarto_julia_deps() {
44-
su "${USERNAME}" -c "~/.juliaup/bin/julia -e 'using Pkg; Pkg.add(\"IJulia\")'"
50+
local deps=$1
51+
deps=$(echo "${deps}" | sed 's/,/","/g')
52+
su "${USERNAME}" -c "~/.juliaup/bin/julia -e 'using Pkg; Pkg.add.([\"${deps}\"])'"
4553
}
4654

47-
case ${DEPENDENCIES} in
48-
all)
49-
quarto_r_deps
50-
quarto_python_deps
51-
quarto_julia_deps
52-
;;
53-
r)
54-
quarto_r_deps
55-
;;
56-
python)
57-
quarto_python_deps
58-
;;
59-
julia)
60-
quarto_julia_deps
61-
;;
62-
esac
55+
quarto_r_deps ${R_DEPS}
56+
quarto_python_deps ${PYTHON_DEPS}
57+
quarto_julia_deps ${JULIA_DEPS}

0 commit comments

Comments
 (0)