diff --git a/CLAUDE.md b/CLAUDE.md index a86e4f472..9ebb1ac8d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -84,10 +84,12 @@ frame (so it stays correct across wind direction changes during flight). This is a Julia package developed with a workspace: `Project.toml` declares `[workspace] projects = ["examples", "examples_3d", "docs", "test"]`, each with its own -`Project.toml`/manifest. +`Project.toml`, all sharing the root `Manifest-v.toml`. -- **Install/setup**: `cd bin && ./install` (installs Julia via juliaup, sets up `Revise` globally). - `./install --update` refreshes an existing setup. +- **Install/setup**: `./bin/install` copies `Manifest-v.toml.default`, instantiates and + precompiles with the Julia on the PATH (`JULIAUP_CHANNEL=1.12 ./bin/install` picks another); + `--update` runs `Pkg.update` on the live manifest instead. Revise goes in the global environment + by hand. - **Launch a dev REPL**: `./bin/run_julia` (activates the right project, forwards script args). - **Build a system image** (much faster startup/time-to-first-plot): `cd bin && ./create_sys_image` (can take ~30 min); relaunch via `./bin/run_julia` afterward. diff --git a/bin/install b/bin/install index e14ff2e51..f4994336a 100755 --- a/bin/install +++ b/bin/install @@ -2,21 +2,20 @@ # SPDX-FileCopyrightText: 2025 Uwe Fechner # SPDX-License-Identifier: MIT -_yes_to_all=false update=false print_usage() { - echo "Usage:" - echo "./install" - echo "./install --update" - echo "./install -y" - echo "./install --yes" - echo "./install --update -y" - echo "./install -h" - echo "./install --help" + echo "Usage: ./install [--update] [-y] [-h]" + echo + echo "Installs the packages pinned in Manifest-v.toml.default with the Julia on" + echo "the PATH and precompiles them. Choose another Julia with JULIAUP_CHANNEL, e.g." + echo "JULIAUP_CHANNEL=1.12 ./install" + echo + echo " --update update the packages in the live manifest; the .default is untouched" + echo " -y, --yes run without asking anything (the default, kept for scripts)" + echo " -h, --help show this help" } -# Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in -h|--help) @@ -28,11 +27,10 @@ while [[ $# -gt 0 ]]; do shift ;; -y|--yes) - _yes_to_all=true shift ;; *) - echo "Invalid parameter! Use:" + echo "Invalid parameter!" print_usage exit 1 ;; @@ -43,230 +41,50 @@ if [[ $(basename $(pwd)) == "bin" ]]; then cd .. fi -# Check if juliaup is installed -if ! command -v juliaup &> /dev/null; then - echo "Error: juliaup is not installed. Please install it first." - case "$(uname -s)" in - Linux|Darwin) - echo " curl -fsSL https://install.julialang.org | sh -s -- --default-channel 1.11" - ;; - MINGW*|MSYS*|CYGWIN*) - echo " winget install --name Julia --id 9NJNWW8PVKMN -e -s msstore" - ;; - *) - echo " See https://github.com/JuliaLang/juliaup for installation instructions." - ;; - esac - exit 1 -fi - -# Check available disk space in home directory (require at least 5 GB) -_required_kb=$((5 * 1024 * 1024)) -_available_kb=$(df -k "$HOME" | awk 'NR==2 {print $4}') -if [[ -z "${_available_kb:-}" ]]; then - echo "Error: Could not determine free disk space for $HOME." - exit 1 -fi -if (( _available_kb < _required_kb )); then - _available_gb=$(awk -v kb="$_available_kb" 'BEGIN {printf "%.2f", kb/1024/1024}') - echo "Error: Not enough free disk space in $HOME." - echo "At least 5.00 GB required, found ${_available_gb} GB." +if ! command -v julia &> /dev/null; then + echo "Error: julia is not on the PATH. Install it with juliaup first:" + echo " https://github.com/JuliaLang/juliaup" exit 1 fi -unset _required_kb _available_kb _available_gb -# Ask which Julia version to use -# Default to the newest of 1.13/1.12 if it is already installed and is the current default, -# otherwise fall back to 1.11 -if juliaup status 2>/dev/null | grep '^\s*\*' | grep -q '1\.13'; then - _default_choice=3 - _default_julia="1.13" -elif juliaup status 2>/dev/null | grep '^\s*\*' | grep -q '1\.12'; then - _default_choice=2 - _default_julia="1.12" -else - _default_choice=1 - _default_julia="1.11" -fi +julia_major=$(bin/julia_major) +echo "Using Julia $julia_major" -if [[ $_yes_to_all == true ]]; then - _julia_choice="" - echo "Using Julia version: ${_default_julia}" -else - echo "Which Julia version do you want to use?" - echo " 1) Julia 1.11" - echo " 2) Julia 1.12" - echo " 3) Julia 1.13" - read -rp "Enter 1, 2 or 3 [default: ${_default_choice}]: " _julia_choice -fi - -case "${_julia_choice}" in - 1) - _desired_julia="1.11" - ;; - 2) - _desired_julia="1.12" - ;; - 3) - _desired_julia="1.13" - ;; - "") - _desired_julia="${_default_julia}" - ;; +case $julia_major in + 1.11|1.12|1.13) ;; *) - echo "Invalid choice: '${_julia_choice}'. Please enter 1, 2 or 3." + echo "Error: Julia $julia_major is not supported, only 1.11, 1.12 and 1.13." + echo "Install one with juliaup and select it with e.g." + echo " JULIAUP_CHANNEL=1.11 ./install" exit 1 ;; esac -echo "Installing and activating Julia ${_desired_julia}..." -juliaup add "${_desired_julia}" -juliaup default "${_desired_julia}" -echo "Julia ${_desired_julia} is now the default." -echo - -# Detect Julia version -julia_version=$(julia --version | awk '{print($3)}') -julia_major=${julia_version:0:3} -if [[ $julia_major == "1.1" ]]; then - julia_major=${julia_version:0:4} -fi - -echo "Detected Julia version: $julia_version (major: $julia_major)" export JULIA_PKG_SERVER_REGISTRY_PREFERENCE=eager -echo "Ensuring Revise is installed in the global Julia environment..." -_revise_code=' -using Pkg -Pkg.activate() -if Base.find_package("Revise") === nothing - Pkg.add("Revise") -end -' - -julia --startup-file=no -e "$_revise_code" -unset _revise_code - -if [[ "$(uname -s)" == "Darwin" ]]; then - # Avoid Tk backend issues on macOS (e.g. non-responsive close button in ControlPlots windows). - # Keep user override if MPLBACKEND is already set. - if [[ -z "${MPLBACKEND:-}" ]]; then - export MPLBACKEND=qtagg - fi -fi - -# Detect current git branch -if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 ; then - branch=$(git rev-parse --abbrev-ref HEAD | sed 's/\//-/g') -else - branch="" -fi - -# Delete any existing custom system image for this Julia version +# A system image built against the previous manifest is stale. SOFILE="bin/kps-image-${julia_major}.so" if test -f "$SOFILE"; then echo "Deleting old system image: $SOFILE" rm -f "$SOFILE" fi -# Only accept Julia 1.11, 1.12 and 1.13 -if [[ $julia_major != "1.11" ]] && [[ $julia_major != "1.12" ]] && [[ $julia_major != "1.13" ]]; then - echo "Error: Julia $julia_major is not supported. Only Julia 1.11, 1.12 and 1.13 are supported." - echo "You can install Julia 1.11 with the following commands:" - echo "juliaup add 1.11" - echo "juliaup default 1.11" +manifest="Manifest-v${julia_major}.toml" +if [ ! -f "${manifest}.default" ]; then + echo "Error: ${manifest}.default not found" exit 1 fi - -if [[ $update == false ]]; then - # Copy the appropriate default manifest - if [ -f "Manifest-v${julia_major}.toml.default" ]; then - cp "Manifest-v${julia_major}.toml.default" "Manifest-v${julia_major}.toml" - echo "Copied Manifest-v${julia_major}.toml.default to Manifest-v${julia_major}.toml" - else - echo "Warning: Manifest-v${julia_major}.toml.default not found" - exit 1 - fi -else - # Update mode: start from a clean state without a manifest and let Pkg.update() generate it. - rm -f Manifest.toml "Manifest-v${julia_major}.toml" - echo "--update selected: removed existing manifests for Julia ${julia_major}" -fi - -# Remove any existing Manifest.toml symlink (left by a previous install run) so Julia -# creates a fresh regular file rather than writing through the old symlink. -# Also remove the version-specific symlink if it is a symlink (not a real file), to -# prevent Julia from writing through it into the wrong manifest. -if [ -L "Manifest.toml" ]; then - rm -f Manifest.toml - echo "Removed stale symlink Manifest.toml" -fi -if [ -L "Manifest-v${julia_major}.toml" ]; then - rm -f "Manifest-v${julia_major}.toml" - echo "Removed stale symlink Manifest-v${julia_major}.toml" -fi - -# Instantiate the project -FAILED_RESOLVES=() -RETRIED_RESOLVES=() if [[ $update == true ]]; then - echo "Updating main project..." + [ -f "$manifest" ] || cp "${manifest}.default" "$manifest" + echo "Updating the packages in $manifest..." + julia --project -e 'using Pkg; Pkg.update()' else - echo "Instantiating project..." + cp "${manifest}.default" "$manifest" + echo "Copied ${manifest}.default to $manifest" + echo "Instantiating the workspace..." + julia --project -e 'using Pkg; Pkg.instantiate()' fi -_ec=0; KITEMODELS_INSTALL_UPDATE="$update" julia --project -e ' -using Pkg -# Resolve in normal mode, update in --update mode. Both paths regenerate a manifest -# for the current Julia version and avoid stale/cross-version manifest issues. -function ensure_general_registry() - regs = try - Pkg.Registry.reachable_registries() - catch - Pkg.Registry.update() - Pkg.Registry.reachable_registries() - end - if !any(r -> r.name == "General", regs) - Pkg.Registry.add("General") - else - Pkg.Registry.update() - end -end -try - ensure_general_registry() - if get(ENV, "KITEMODELS_INSTALL_UPDATE", "false") == "true" - Pkg.update() - else - Pkg.resolve() - end - Pkg.instantiate() -catch e - @warn "Main project package operation failed, attempting clean retry..." exception=e - proj_dir = dirname(Base.active_project()) - # Remove all manifest files to force a completely clean resolve - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - ensure_general_registry() - if get(ENV, "KITEMODELS_INSTALL_UPDATE", "false") == "true" - Pkg.update() - else - Pkg.resolve() - end - Pkg.instantiate() - exit(2) -end -' || _ec=$? -if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("main project") -elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("main project"); fi -# If package operations created a plain Manifest.toml (Julia 1.12 behavior), rename it -# to the version-specific filename so the rest of the scripts stay consistent. -if [ -f "Manifest.toml" ]; then - mv Manifest.toml "Manifest-v${julia_major}.toml" - echo "Renamed Manifest.toml to Manifest-v${julia_major}.toml" -fi # Run Pkg.precompile() for a project and abort if any package fails. # Pkg.precompile() exits 0 even when individual packages fail, so we also grep # the merged stdout+stderr for failure markers (after stripping ANSI color codes). @@ -281,13 +99,15 @@ run_precompile() { _precompile_rc=${PIPESTATUS[0]} set -e # Strip ANSI escape codes, then check for failure markers + local _failure="Failed to precompile|dependencies? errored" if [[ $_precompile_rc -ne 0 ]] || \ - sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' "$_plog" | grep -qE "Failed to precompile|dependencies? errored"; then + sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' "$_plog" | grep -qE "$_failure"; then if [[ "$_proj" == "--project=docs" ]] && \ grep -q "XML_SetAllocTrackerActivationThreshold" "$_plog" && \ grep -q "pyexpat" "$_plog"; then - echo "Warning: Skipping docs precompile due to Conda Python/expat mismatch (pyexpat symbol error)." - echo "Installation will continue; docs can be precompiled later after repairing the Conda env." + echo "Warning: Skipping docs precompile due to a Conda Python/expat mismatch" + echo "(pyexpat symbol error). Installation continues; precompile docs later," + echo "after repairing the Conda env." rm -f "$_plog" return 0 fi @@ -298,329 +118,27 @@ run_precompile() { rm -f "$_plog" } -echo "Precompiling main project..." -run_precompile "--project" - -# Instantiate all sub-projects: examples, test, examples_3d, docs -if [[ $julia_major == "1.11" ]]; then - echo "Instantiating examples and test project for Julia $julia_major..." - # Resolve sub-projects independently to avoid version conflicts when the main - # manifest contains versions newer than the local registry snapshot. - rm -f examples/Manifest*.toml test/Manifest*.toml examples_3d/Manifest*.toml - cp Manifest-v1.11.toml examples/Manifest-v1.11.toml - cp Manifest-v1.11.toml test/Manifest-v1.11.toml - cp Manifest-v1.11.toml examples_3d/Manifest-v1.11.toml - _ec=0; julia --project=examples -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("examples (1.11)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("examples (1.11)"); fi - echo "Precompiling examples project..." - run_precompile "--project=examples" - _ec=0; julia --project=test -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("test (1.11)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("test (1.11)"); fi - echo "Precompiling test project and running the tests..." - run_precompile "--project=test" - julia --project -e 'using Pkg; Pkg.test()' - _ec=0; julia --project=examples_3d -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("examples_3d (1.11)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("examples_3d (1.11)"); fi - echo "Precompiling examples_3d project..." - run_precompile "--project=examples_3d" - - # Rename the manifest file to version-specific name - if [ -f "examples/Manifest.toml" ]; then - mv examples/Manifest.toml examples/Manifest-v${julia_major}.toml - echo "Renamed examples/Manifest.toml to examples/Manifest-v${julia_major}.toml" - fi - if [ -f "test/Manifest.toml" ]; then - mv test/Manifest.toml test/Manifest-v${julia_major}.toml - echo "Renamed test/Manifest.toml to test/Manifest-v${julia_major}.toml" - fi - if [ -f "examples_3d/Manifest.toml" ]; then - mv examples_3d/Manifest.toml examples_3d/Manifest-v${julia_major}.toml - echo "Renamed examples_3d/Manifest.toml to examples_3d/Manifest-v${julia_major}.toml" - fi - # Docs resolves independently (different dep tree; seeding from main causes missing extensions) - rm -f docs/Manifest*.toml - _ec=0; julia --project=docs -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("docs (1.11)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("docs (1.11)"); fi - echo "Precompiling docs project..." - run_precompile "--project=docs" - if [ -f "docs/Manifest.toml" ]; then - mv docs/Manifest.toml docs/Manifest-v${julia_major}.toml - echo "Renamed docs/Manifest.toml to docs/Manifest-v${julia_major}.toml" - fi -else - echo "Julia $julia_major: instantiating all sub-projects..." - # Resolve sub-projects independently to avoid version conflicts when the main - # manifest contains versions newer than the local registry snapshot. - rm -f examples/Manifest*.toml test/Manifest*.toml examples_3d/Manifest*.toml - _ec=0; julia --project=examples -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("examples (1.12)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("examples (1.12)"); fi - echo "Precompiling examples project..." - run_precompile "--project=examples" - _ec=0; julia --project=test -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("test (1.12)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("test (1.12)"); fi - echo "Precompiling test project and running the tests..." - run_precompile "--project=test" - julia --project -e 'using Pkg; Pkg.test()' - echo "Precompiling examples_3d project..." - _ec=0; julia --project=examples_3d -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("examples_3d (1.12)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("examples_3d (1.12)"); fi - run_precompile "--project=examples_3d" - # Docs resolves independently (different dep tree; seeding from main causes missing extensions) - rm -f docs/Manifest*.toml - _ec=0; julia --project=docs -e ' -using Pkg -try - Pkg.resolve() - Pkg.instantiate() -catch e - @warn "Pkg.resolve()/instantiate() failed, attempting clean resolve..." exception=e - proj_dir = dirname(Base.active_project()) - for f in readdir(proj_dir) - if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default") - rm(joinpath(proj_dir, f), force=true) - end - end - Pkg.resolve() - Pkg.instantiate() - exit(2) -end -' || _ec=$? - if [[ $_ec -eq 2 ]]; then RETRIED_RESOLVES+=("docs (1.12)") - elif [[ $_ec -ne 0 ]]; then FAILED_RESOLVES+=("docs (1.12)"); fi - echo "Precompiling docs project..." - run_precompile "--project=docs" - if [ -f "examples/Manifest.toml" ]; then - mv examples/Manifest.toml examples/Manifest-v${julia_major}.toml - echo "Renamed examples/Manifest.toml to examples/Manifest-v${julia_major}.toml" - fi - if [ -f "test/Manifest.toml" ]; then - mv test/Manifest.toml test/Manifest-v${julia_major}.toml - echo "Renamed test/Manifest.toml to test/Manifest-v${julia_major}.toml" - fi - if [ -f "examples_3d/Manifest.toml" ]; then - mv examples_3d/Manifest.toml examples_3d/Manifest-v${julia_major}.toml - echo "Renamed examples_3d/Manifest.toml to examples_3d/Manifest-v${julia_major}.toml" - fi - if [ -f "docs/Manifest.toml" ]; then - mv docs/Manifest.toml docs/Manifest-v${julia_major}.toml - echo "Renamed docs/Manifest.toml to docs/Manifest-v${julia_major}.toml" - fi -fi -julia --project=examples -e 'using MakieControlPlots, DSP' || true -julia --project=examples_3d -e 'using MakieControlPlots' || true -julia --project=examples_3d -e 'using KiteViewers' || true - -echo -if [[ ${#FAILED_RESOLVES[@]} -eq 0 && ${#RETRIED_RESOLVES[@]} -eq 0 ]]; then - echo "Resolve/instantiate report: all resolve calls succeeded on the first attempt." -elif [[ ${#FAILED_RESOLVES[@]} -eq 0 ]]; then - echo "Resolve/instantiate report: all resolve calls succeeded, but the following needed a clean retry" - echo " (original pinned package versions were NOT used):" - for _label in "${RETRIED_RESOLVES[@]}"; do - echo " - ${_label}" - done -else - echo "Resolve/instantiate report: the following resolve calls FAILED:" - for _label in "${FAILED_RESOLVES[@]}"; do - echo " - ${_label}" - done - if [[ ${#RETRIED_RESOLVES[@]} -gt 0 ]]; then - echo " The following needed a clean retry (original pinned package versions were NOT used):" - for _label in "${RETRIED_RESOLVES[@]}"; do - echo " - ${_label}" - done - fi -fi - -run_precompile "--project=examples" +for _proj in "" examples examples_3d test docs; do + echo "Precompiling ${_proj:-main} project..." + run_precompile "--project${_proj:+=$_proj}" +done -# Handle .JETLSConfig.toml configuration file -_jetls_warning=0 -if [ ! -f ".JETLSConfig.toml" ]; then - if [ -f ".JETLSConfig.toml.default" ]; then - cp .JETLSConfig.toml.default .JETLSConfig.toml - echo "Copied .JETLSConfig.toml.default to .JETLSConfig.toml" - else - echo "Warning: .JETLSConfig.toml.default not found" - fi -else - # Only warn if the files differ - if [ -f ".JETLSConfig.toml.default" ]; then - if ! cmp -s ".JETLSConfig.toml" ".JETLSConfig.toml.default"; then - _jetls_warning=1 - fi - fi +jetls=.JETLSConfig.toml +if [ ! -f "$jetls" ] && [ -f "$jetls.default" ]; then + cp "$jetls.default" "$jetls" + echo "Copied $jetls.default to $jetls" +elif [ -f "$jetls.default" ] && ! cmp -s "$jetls" "$jetls.default"; then + echo "Warning: $jetls differs from $jetls.default and was not overwritten." fi echo printf "\033[1;32mInstallation complete!\033[0m\n" echo -echo "You can now launch Julia by typing" -echo "cd .." -echo "bin/run_julia" -echo "and then get the menu with the examples by typing:" +echo "You can now launch Julia with bin/run_julia and get the menu with the examples" +echo "by typing:" echo "menu()" - -# Add alias to shell configuration file -if [[ "$(uname -s)" == "Linux" && -f ~/.bashrc ]]; then - if ! grep -q "alias jl='bin/run_julia'" ~/.bashrc; then - echo "alias jl='bin/run_julia'" >> ~/.bashrc - echo - echo "Added alias 'jl' to ~/.bashrc" - echo "Run 'source ~/.bashrc' or restart your terminal to use it" - fi -elif [[ "$(uname -s)" == "Darwin" ]]; then - # On macOS, check for zsh (default since Catalina) or bash configuration files - _config_file="" - if [[ -f ~/.zshrc ]]; then - _config_file=~/.zshrc - elif [[ -f ~/.bash_profile ]]; then - _config_file=~/.bash_profile - elif [[ -f ~/.bashrc ]]; then - _config_file=~/.bashrc - fi - - if [[ -n "$_config_file" ]]; then - if ! grep -q "alias jl='bin/run_julia'" "$_config_file"; then - echo "alias jl='bin/run_julia'" >> "$_config_file" - echo - echo "Added alias 'jl' to $_config_file" - echo "Run 'source $_config_file' or restart your terminal to use it" - fi - fi - unset _config_file +if ! julia --startup-file=no -e 'exit(Base.find_package("Revise") === nothing)'; then + echo + echo "bin/run_julia needs Revise in your global Julia environment. Add it with:" + echo " julia -e 'using Pkg; Pkg.add(\"Revise\")'" fi - -echo - -# Warn if .JETLSConfig.toml already existed -if [[ $_jetls_warning -eq 1 ]]; then - echo "Warning: .JETLSConfig.toml already exists and was not overwritten." - echo "If you want to use the default configuration, delete it and run this script again." -fi \ No newline at end of file diff --git a/bin/julia_major b/bin/julia_major new file mode 100755 index 000000000..dfac72132 --- /dev/null +++ b/bin/julia_major @@ -0,0 +1,7 @@ +#!/bin/bash -eu +# SPDX-FileCopyrightText: 2026 Bart van de Lint +# SPDX-License-Identifier: MIT + +# Prints the major.minor version of the Julia on the PATH, e.g. 1.12 +julia_version=$(julia --version) +echo "${julia_version##* }" | cut -d. -f1,2 diff --git a/bin/update_default_manifest b/bin/update_default_manifest index 73258f9f2..c232d817e 100755 --- a/bin/update_default_manifest +++ b/bin/update_default_manifest @@ -2,63 +2,16 @@ # SPDX-FileCopyrightText: 2025 Uwe Fechner # SPDX-License-Identifier: MIT +# Updates all packages with the Julia on the PATH and writes the result to +# Manifest-v.toml.default. Choose another Julia with e.g. +# JULIAUP_CHANNEL=1.12 ./update_default_manifest + if [[ $(basename $(pwd)) == "bin" ]]; then cd .. fi -# Ask which Julia version to use -# Default to 1.12 if it is already installed and is the current default, otherwise 1.11 -if juliaup status 2>/dev/null | grep '^\s*\*' | grep -q '1\.12'; then - _default_choice=2 - _default_julia="1.12" -else - _default_choice=1 - _default_julia="1.11" -fi - -echo "Which Julia version do you want to update the manifest for?" -echo " 1) Julia 1.11" -echo " 2) Julia 1.12" -read -rp "Enter 1 or 2 [default: ${_default_choice}]: " _julia_choice - -case "${_julia_choice}" in - 1) - _desired_julia="1.11" - ;; - 2) - _desired_julia="1.12" - ;; - "") - _desired_julia="${_default_julia}" - ;; - *) - echo "Invalid choice: '${_julia_choice}'. Please enter 1 or 2." - exit 1 - ;; -esac -echo "Using Julia version: ${_desired_julia}" - -# Temporarily switch to the chosen Julia version -juliaup default "${_desired_julia}" -echo "Switched to Julia ${_desired_julia}." -echo - -cd bin -./install --update -y - -julia_version=$(julia --version | awk '{print($3)}') -julia_major=${julia_version:0:3} -if [[ $julia_major == "1.1" ]]; then - julia_major=${julia_version:0:4} -fi +bin/install --update -cd .. -if [[ $julia_major == "1.11" ]]; then - cp examples/Manifest-v1.11.toml Manifest-v1.11.toml.default - rm -rf ~/.julia/compiled/v1.11/KiteModels/ - echo "Updated Manifest-v1.11.toml.default !" -else - cp Manifest-v1.12.toml Manifest-v1.12.toml.default - rm -rf ~/.julia/compiled/v1.12/KiteModels/ - echo "Updated Manifest-v1.12.toml.default !" -fi \ No newline at end of file +julia_major=$(bin/julia_major) +cp "Manifest-v${julia_major}.toml" "Manifest-v${julia_major}.toml.default" +echo "Updated Manifest-v${julia_major}.toml.default !" diff --git a/changelog.d/323-cleanup-bin-install-runs-the-test-suite-.md b/changelog.d/323-cleanup-bin-install-runs-the-test-suite-.md new file mode 100644 index 000000000..a7df873aa --- /dev/null +++ b/changelog.d/323-cleanup-bin-install-runs-the-test-suite-.md @@ -0,0 +1,7 @@ + +### Changed +- `bin/install` only installs: it copies `Manifest-v.toml.default`, instantiates and precompiles with the Julia on the PATH. It no longer runs the tests, resolves, calls `juliaup add`/`juliaup default`, adds Revise to the global environment or appends an alias to `~/.bashrc`; select another Julia with `JULIAUP_CHANNEL`. +- `bin/update_default_manifest` updates the manifest of the Julia on the PATH instead of switching the `juliaup` default.