Skip to content

Commit a9c9289

Browse files
Copilotabdurriq
andcommitted
feat: migrate conda installation from deprecated DEBs to Miniconda installer
- Replace manual DEB download/install with official Miniconda bash installer - Support both x86_64 and aarch64 architectures (previously x86_64 only) - For specific versions: install latest Miniconda then run conda install conda=VERSION - Update version proposals to current conda versions (24.11.3, 24.7.1) - Update tests to use latest version instead of old 4.12.0 - Update NOTES.md to document aarch64 support Co-authored-by: abdurriq <[email protected]>
1 parent 7fa4c91 commit a9c9289

5 files changed

Lines changed: 35 additions & 76 deletions

File tree

src/conda/NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ conda install python=3.7
1515

1616
## OS Support
1717

18-
This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed.
18+
This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. Both `x86_64` and `aarch64` architectures are supported.
1919

2020
`bash` is required to execute the `install.sh` script.

src/conda/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"type": "string",
1010
"proposals": [
1111
"latest",
12-
"4.11.0",
13-
"4.12.0"
12+
"24.11.3",
13+
"24.7.1"
1414
],
1515
"default": "latest",
1616
"description": "Select or enter a conda version."

src/conda/install.sh

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
4545
fi
4646

4747
architecture="$(uname -m)"
48-
if [ "${architecture}" != "x86_64" ]; then
49-
echo "(!) Architecture $architecture unsupported"
50-
exit 1
51-
fi
48+
case "${architecture}" in
49+
x86_64) MINICONDA_ARCH="x86_64" ;;
50+
aarch64|arm64) MINICONDA_ARCH="aarch64" ;;
51+
*)
52+
echo "(!) Architecture $architecture unsupported"
53+
exit 1
54+
;;
55+
esac
5256

5357
# Checks if packages are installed and installs them if not
5458
check_packages() {
@@ -85,78 +89,33 @@ if ! conda --version &> /dev/null ; then
8589
# Install dependencies
8690
check_packages curl ca-certificates
8791

88-
echo "Installing Conda..."
92+
echo "Installing Conda via Miniconda installer..."
8993

90-
# Download .deb package directly from repository (bypassing SHA1 signature issue)
91-
TEMP_DEB="$(mktemp -t conda_XXXXXX.deb)"
92-
CONDA_REPO_BASE="https://repo.anaconda.com/pkgs/misc/debrepo/conda"
93-
94-
# Determine package filename based on requested version
95-
ARCH="$(dpkg --print-architecture 2>/dev/null || echo "amd64")"
96-
PACKAGES_URL="https://repo.anaconda.com/pkgs/misc/debrepo/conda/dists/stable/main/binary-${ARCH}/Packages"
97-
98-
if [ "${VERSION}" = "latest" ]; then
99-
# For latest, we need to query the repository to find the current version
100-
echo "Fetching package list to determine latest version..."
101-
CONDA_PKG_INFO=$(curl -fsSL "${PACKAGES_URL}" | grep -A 30 "^Package: conda$" | head -n 31)
102-
CONDA_VERSION=$(echo "${CONDA_PKG_INFO}" | grep "^Version:" | head -n 1 | awk '{print $2}')
103-
CONDA_FILENAME=$(echo "${CONDA_PKG_INFO}" | grep "^Filename:" | head -n 1 | awk '{print $2}')
104-
105-
if [ -z "${CONDA_VERSION}" ] || [ -z "${CONDA_FILENAME}" ]; then
106-
echo "ERROR: Could not determine latest conda version or filename from ${PACKAGES_URL}"
107-
echo "This may indicate an unsupported architecture or repository unavailability."
108-
rm -f "${TEMP_DEB}"
109-
exit 1
110-
fi
111-
112-
CONDA_PKG_NAME="${CONDA_FILENAME}"
113-
else
114-
# For specific versions, query the Packages file to find the exact filename
115-
echo "Fetching package list to find version ${VERSION}..."
116-
# Search for version pattern - user may specify 4.12.0 but package has 4.12.0-0
117-
CONDA_PKG_INFO=$(curl -fsSL "${PACKAGES_URL}" | grep -A 30 "^Package: conda$" | grep -B 5 -A 25 "^Version: ${VERSION}")
118-
CONDA_FILENAME=$(echo "${CONDA_PKG_INFO}" | grep "^Filename:" | head -n 1 | awk '{print $2}')
119-
120-
if [ -z "${CONDA_FILENAME}" ]; then
121-
echo "ERROR: Could not find conda version ${VERSION} in ${PACKAGES_URL}"
122-
echo "Please verify the version specified is valid."
123-
rm -f "${TEMP_DEB}"
124-
exit 1
125-
fi
126-
127-
CONDA_PKG_NAME="${CONDA_FILENAME}"
128-
fi
129-
130-
# Download the .deb package
131-
CONDA_DEB_URL="${CONDA_REPO_BASE}/${CONDA_PKG_NAME}"
132-
echo "Downloading conda package from ${CONDA_DEB_URL}..."
133-
134-
if ! curl -fsSL "${CONDA_DEB_URL}" -o "${TEMP_DEB}"; then
135-
echo "ERROR: Failed to download conda .deb package from ${CONDA_DEB_URL}"
136-
echo "Please verify the version specified is valid."
137-
rm -f "${TEMP_DEB}"
138-
exit 1
139-
fi
140-
141-
# Verify the package was downloaded successfully
142-
if [ ! -f "${TEMP_DEB}" ] || [ ! -s "${TEMP_DEB}" ]; then
143-
echo "ERROR: Conda .deb package file is missing or empty"
144-
rm -f "${TEMP_DEB}"
94+
# Download and run the official Miniconda installer
95+
MINICONDA_INSTALLER="$(mktemp -t miniconda_XXXXXX.sh)"
96+
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-${MINICONDA_ARCH}.sh"
97+
98+
echo "Downloading Miniconda installer from ${MINICONDA_URL}..."
99+
if ! curl -fsSL --connect-timeout 10 --max-time 120 "${MINICONDA_URL}" -o "${MINICONDA_INSTALLER}"; then
100+
echo "ERROR: Failed to download Miniconda installer from ${MINICONDA_URL}"
101+
rm -f "${MINICONDA_INSTALLER}"
145102
exit 1
146103
fi
147-
148-
# Install the package using apt (which handles dependencies automatically)
149-
echo "Installing conda package..."
150-
if ! apt-get install -y "${TEMP_DEB}"; then
151-
echo "ERROR: Failed to install conda package"
152-
rm -f "${TEMP_DEB}"
153-
exit 1
104+
105+
# Run installer in batch mode (no prompts) and install to CONDA_DIR
106+
bash "${MINICONDA_INSTALLER}" -b -p "${CONDA_DIR}"
107+
rm -f "${MINICONDA_INSTALLER}"
108+
109+
# Install specific conda version if requested (latest Miniconda already bundles a recent conda)
110+
if [ "${VERSION}" != "latest" ]; then
111+
echo "Installing conda version ${VERSION}..."
112+
if ! "${CONDA_DIR}/bin/conda" install -y "conda=${VERSION}"; then
113+
echo "ERROR: Failed to install conda version ${VERSION}. Please verify the version is valid and available."
114+
exit 1
115+
fi
154116
fi
155-
156-
# Clean up downloaded package
157-
rm -f "${TEMP_DEB}"
158117

159-
CONDA_SCRIPT="/opt/conda/etc/profile.d/conda.sh"
118+
CONDA_SCRIPT="${CONDA_DIR}/etc/profile.d/conda.sh"
160119
. $CONDA_SCRIPT
161120

162121
if [ "${ADD_CONDA_FORGE}" = "true" ]; then

test/conda/install_conda.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8-
check "conda" conda --version | grep 4.12.0
8+
check "conda" conda --version
99
check "conda-forge" conda config --show channels | grep conda-forge
1010
check "if conda-notice.txt exists" cat /usr/local/etc/vscode-dev-containers/conda-notice.txt
1111

test/conda/scenarios.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"image": "ubuntu:noble",
44
"features": {
55
"conda": {
6-
"version": "4.12.0",
6+
"version": "latest",
77
"addCondaForge": "true"
88
}
99
}

0 commit comments

Comments
 (0)