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
56 changes: 56 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,62 @@ ARG USER_UID=1000
ARG USER_GID=1000
ARG SPACK_GID=2000

# Validate Python site-packages symlink
RUN <<'VALIDATE_PYTHON_SYMLINK'
set -euo pipefail
shopt -s nullglob

SPACK_VIEW_LIB=/opt/spack-environments/phlex-ci/.spack-env/view/lib

# Find all versioned Python site-packages directories
python_dirs=("$SPACK_VIEW_LIB"/python3.*)
count=${#python_dirs[@]}

# Ensure exactly one versioned Python site-packages directory exists
if [ $count -eq 0 ]; then
echo "ERROR: No versioned Python site-packages directory found in $SPACK_VIEW_LIB" >&2
exit 1
elif [ $count -gt 1 ]; then
echo "ERROR: Multiple versioned Python site-packages directories found in $SPACK_VIEW_LIB:" >&2
printf ' %s\n' "${python_dirs[@]}" >&2
exit 1
fi

# Get the single Python directory and its basename
python_dir="${python_dirs[0]}"
python_basename=$(basename "$python_dir")

# Create the symlink if it doesn't exist or update it if it's incorrect
python_link="$SPACK_VIEW_LIB/python"
if [ -L "$python_link" ]; then
current_target=$(readlink "$python_link")
if [ "$current_target" != "$python_basename" ]; then
echo "Updating $python_link -> $python_basename"
ln -sfn "$python_basename" "$python_link"
fi
elif [ -e "$python_link" ]; then
echo "ERROR: $python_link exists but is not a symlink" >&2
exit 1
else
echo "Creating $python_link -> $python_basename"
ln -sn "$python_basename" "$python_link"
fi

# Verify the symlink is correct
if [ ! -L "$python_link" ]; then
echo "ERROR: Failed to create symlink at $python_link" >&2
exit 1
fi

# Verify the symlink target is a valid directory
if [ ! -d "$python_link" ]; then
echo "ERROR: Symlink $python_link does not point to a valid directory" >&2
exit 1
fi

echo "Python symlink validated: $python_link -> $(readlink "$python_link")"
VALIDATE_PYTHON_SYMLINK

# Create the user and add to spack group
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID --create-home $USERNAME \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"python.analysis.extraPaths": [
"${workspaceFolder}/build",
"/opt/spack-environments/phlex-ci/.spack-env/view/lib/root",
"/opt/spack-environments/phlex-ci/.spack-env/view/lib/python3.14/site-packages"
"/opt/spack-environments/phlex-ci/.spack-env/view/lib/python/site-packages"
],
"cmake.cmakePath": "${workspaceFolder}/.devcontainer/cmake_wrapper.sh",
"cmake.ctestPath": "${workspaceFolder}/.devcontainer/ctest_wrapper.sh",
Expand Down