Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ It supports initialising all environments or specific ones based on the provided
### Script Details

- **Options**:
- `--what/-w`: Specify which environment(s) to initialise (`all`, `r`, `python`, `julia`).
- `--what/-w`: Specify which environment(s) to initialise (`all`, `r`, `python (uv)`, `julia`).
- `--force/-f`: Force reinstallation of the specified environment(s).
- `--help/-h`: Display help message and exit.
- **Functionality**: The script installs necessary dependencies for R, Python, and Julia, inside environments.
- For R, it sets up `renv` and installs required packages.
- For Python, it sets up a virtual environment and installs required libraries.
- For Python, it sets up uv and installs required libraries.
- For Julia, it sets up an environment and installs required packages.

## Contributing
Expand Down
21 changes: 17 additions & 4 deletions init-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ show_help() {
echo " --what/-w: Specify what to initialise (default: all)."
echo " all: Initialise R (renv), Python (virtualenv), and Julia (project)."
echo " r: Initialise R (renv)."
echo " python: Initialise Python (virtualenv)."
echo " python: Initialise Python (uv)."
echo " julia: Initialise Julia (project)."
echo " --force/-f: Force initialisation regardless of existing files."
echo " --help/-h: Show this help message."
}

initialise_r() {
if [ "$FORCE" = true ] || [ ! -f "renv.lock" ]; then
if grep -q 'source("renv/activate.R")' .Rprofile; then
sed -i '' '/source("renv\/activate.R")/d' .Rprofile
fi
Rscript -e 'renv::init(bare = FALSE)'
Rscript -e 'renv::install("rmarkdown")'
Rscript -e 'renv::install(c("rmarkdown", "prompt", "languageserver", "lintr", "styler", "cli"))'
Rscript -e 'renv::snapshot(type = "all")'
fi
}
Expand All @@ -28,6 +31,16 @@ initialise_python() {
fi
}

initialise_uv() {
if [ "$FORCE" = true ] || [ ! -f "uv.lock" ]; then
uv init --no-package --vcs none --bare --no-readme --author-from none
uv venv
source .venv/bin/activate
uv add jupyter papermill
uv sync
fi
}

initialise_julia() {
if [ "$FORCE" = true ] || [ ! -f "Project.toml" ]; then
julia -e 'using Pkg; Pkg.activate("."); Pkg.instantiate()'
Expand Down Expand Up @@ -63,14 +76,14 @@ done
case $WHAT in
all)
initialise_r
initialise_python
initialise_uv
initialise_julia
;;
r)
initialise_r
;;
python)
initialise_python
initialise_uv
;;
julia)
initialise_julia
Expand Down