|
2 | 2 | # |
3 | 3 | # Install conda dependencies from one or more requirements files. |
4 | 4 | # |
5 | | -# Usage: install-conda-deps.sh [options] requirements1.txt [requirements2.txt ...] |
| 5 | +# Usage: install-conda-deps.sh [options] file1.txt [--x86-only:file2.txt] [file3.txt ...] |
6 | 6 | # |
7 | | -# Options: |
8 | | -# --x86-only Only install if running on x86_64 architecture (skip on ARM) |
| 7 | +# Arguments: |
| 8 | +# file.txt Regular requirements file (installed on all architectures) |
| 9 | +# --x86-only:file.txt x86-only requirements file (skipped on ARM64) |
9 | 10 | # |
10 | 11 | # This script installs all dependencies in a SINGLE resolver call to prevent |
11 | | -# version regressions when derivative images add packages. Always pass ALL |
12 | | -# requirements files together (e.g., core.txt + classify.txt for classify image). |
| 12 | +# version regressions when derivative images add packages. x86-only files are |
| 13 | +# included in the same resolver call on x86, ensuring consistent dependency |
| 14 | +# resolution across all packages. |
| 15 | +# |
| 16 | +# Examples: |
| 17 | +# # Install core packages only |
| 18 | +# install-conda-deps.sh baseimage.txt core.txt |
| 19 | +# |
| 20 | +# # Install with x86-only packages (single resolver call on x86, skips x86-only on ARM) |
| 21 | +# install-conda-deps.sh baseimage.txt core.txt --x86-only:core-x86.txt |
| 22 | +# |
| 23 | +# # Multiple x86-only files |
| 24 | +# install-conda-deps.sh baseimage.txt core.txt classify.txt --x86-only:classify-x86.txt phylo.txt --x86-only:phylo-x86.txt |
13 | 25 |
|
14 | 26 | set -e -o pipefail |
15 | 27 |
|
16 | 28 | # Architecture detection |
17 | 29 | ARCH=$(uname -m) |
18 | | -X86_ONLY=false |
19 | 30 |
|
20 | 31 | is_x86() { |
21 | 32 | [[ "$ARCH" == "x86_64" || "$ARCH" == "amd64" ]] |
@@ -49,41 +60,52 @@ stop_keepalive() { |
49 | 60 |
|
50 | 61 | trap stop_keepalive EXIT SIGINT SIGQUIT SIGTERM |
51 | 62 |
|
52 | | -# Parse options and build requirements arguments |
| 63 | +# Parse arguments and build requirements list |
53 | 64 | REQUIREMENTS="" |
| 65 | +SKIPPED_X86_FILES="" |
| 66 | + |
54 | 67 | for arg in "$@"; do |
55 | | - case "$arg" in |
56 | | - --x86-only) |
57 | | - X86_ONLY=true |
58 | | - ;; |
59 | | - *) |
60 | | - if [ -f "$arg" ]; then |
61 | | - echo "Adding requirements from: $arg" |
62 | | - REQUIREMENTS="$REQUIREMENTS --file $arg" |
| 68 | + if [[ "$arg" == --x86-only:* ]]; then |
| 69 | + # Extract filename from --x86-only:filename.txt |
| 70 | + file="${arg#--x86-only:}" |
| 71 | + if is_x86; then |
| 72 | + if [ -f "$file" ]; then |
| 73 | + echo "Adding x86-only requirements from: $file" |
| 74 | + REQUIREMENTS="$REQUIREMENTS --file $file" |
63 | 75 | else |
64 | | - echo "Warning: requirements file not found: $arg" >&2 |
| 76 | + echo "Warning: x86-only requirements file not found: $file" >&2 |
65 | 77 | fi |
66 | | - ;; |
67 | | - esac |
| 78 | + else |
| 79 | + echo "Skipping x86-only file on $ARCH: $file" |
| 80 | + SKIPPED_X86_FILES="$SKIPPED_X86_FILES $file" |
| 81 | + fi |
| 82 | + else |
| 83 | + # Regular requirements file |
| 84 | + if [ -f "$arg" ]; then |
| 85 | + echo "Adding requirements from: $arg" |
| 86 | + REQUIREMENTS="$REQUIREMENTS --file $arg" |
| 87 | + else |
| 88 | + echo "Warning: requirements file not found: $arg" >&2 |
| 89 | + fi |
| 90 | + fi |
68 | 91 | done |
69 | 92 |
|
70 | | -# Skip x86-only packages on non-x86 architectures |
71 | | -if $X86_ONLY && ! is_x86; then |
72 | | - echo "Skipping x86-only packages on $ARCH architecture" |
73 | | - exit 0 |
74 | | -fi |
75 | | - |
76 | 93 | if [ -z "$REQUIREMENTS" ]; then |
| 94 | + if [ -n "$SKIPPED_X86_FILES" ]; then |
| 95 | + echo "No packages to install (all files were x86-only and skipped on $ARCH)" |
| 96 | + exit 0 |
| 97 | + fi |
77 | 98 | echo "Error: No valid requirements files provided" >&2 |
78 | 99 | exit 1 |
79 | 100 | fi |
80 | 101 |
|
81 | 102 | echo "" |
82 | 103 | echo "Installing conda dependencies..." |
| 104 | +echo "Architecture: $ARCH" |
83 | 105 | echo "micromamba version: $(micromamba --version)" |
84 | 106 | echo "" |
85 | 107 |
|
86 | | -# Install all dependencies together |
| 108 | +# Install all dependencies together in single resolver call |
87 | 109 | start_keepalive |
88 | 110 | micromamba install -y -n base $REQUIREMENTS |
89 | 111 | stop_keepalive |
|
0 commit comments