Skip to content
Open
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
7 changes: 5 additions & 2 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash

CODE_TEMPLATE=/usr/local/src/code_template
CODE=/workspaces/code
INFRA=/workspaces/code
CODE=/workspaces

ln -s $CODE_TEMPLATE/.venv $CODE/.venv
# .venv is infra-private; external and libneo are workspace-shared
ln -s $CODE_TEMPLATE/.venv $INFRA/.venv
mkdir -p $CODE/external
ln -s $CODE_TEMPLATE/external/fgsl-1.6.0 $CODE/external/fgsl-1.6.0
cp -r $CODE_TEMPLATE/libneo $CODE/libneo

Expand Down
125 changes: 0 additions & 125 deletions .github/workflows/main.yml

This file was deleted.

14 changes: 12 additions & 2 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,27 @@ jobs:
libmetis-dev \
libboost-all-dev

# TODO(infra-relocation): this workflow runs on version tags only and is
# NOT exercised by PR CI. After the infra relocation, setup.sh builds the
# shared deps into $CODE/external (the workspace, parent of this checkout),
# so the steps below must build there and bundle external/ into the release
# tarball alongside the infra content. Validate on a real tag before
# cutting the next release; main.yml still consumes the pinned old release.
- name: Setup
run: |
set -e
source scripts/setup.sh
pushd external
../scripts/setup/mfem.sh
CODE="$(cd .. && pwd)"
pushd "$CODE/external"
"$GITHUB_WORKSPACE/scripts/setup/mfem.sh"
popd

- name: Build tarball
run: |
set -e
CODE="$(cd .. && pwd)"
# flat release archive: infra content + the shared external/ at root
cp -r "$CODE/external" ./external
tar -czf /tmp/code.tar.gz .

- name: Create GitHub Release
Expand Down
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ CODE is based around our standard Debian bookworm system at ITPcp and provides
- Container definitions
- VSCode settings

## Layout

This repository is the `infra` directory of a workspace. The workspace is the
environment variable `$CODE`; this repository is `$INFRA`, equal to
`$CODE/infra`. The code checkouts sit in the workspace next to `infra`:

$CODE/
infra/ this repository (activation, setup scripts, modules, .venv)
external/ prebuilt third-party libs, shared by all codes
libneo/ code checkout
SIMPLE/ code checkout
...

Activation exports both. `$INFRA` holds the infra-private paths (`scripts`,
`.venv`, `modules`). `$CODE` is the workspace root, so the codes resolve their
dependencies as `$CODE/<name>` and read prebuilt libraries from
`$CODE/external`.

## Getting Started

If you haven't done so earlier, set up your SSH keys in `~/.ssh` via `ssh-keygen`
Expand All @@ -35,30 +53,31 @@ to install Debian Linux via WSL2. Then follow the Linux instructions.

### Initial setup

Clone the repository to your working copy, at the institute this is
Clone this repository into an `infra` directory inside your workspace. At the
institute the workspace is `/proj/plasma/CODE/<username>`:

git clone git@github.com:itpplasma/code /proj/plasma/CODE/<username>
git clone git@github.com:itpplasma/code /proj/plasma/CODE/<username>/infra

Then open the directory in VS Code with
Open the workspace in VS Code with

code code
code /proj/plasma/CODE/<username>

When asked to initialize the devcontainer, remove the message.
Run the setup script manually with

scripts/setup.sh
infra/scripts/setup.sh

The setup will install external dependencies and create
a Python virtual environment in the hidden `.venv` directory.
The setup installs external dependencies and creates the Python virtual
environment in `infra/.venv`.

Finally, activate the environment with

source activate.sh
source infra/activate.sh

To use this environment as a standard, put the activation
script into bashrc with

echo "source $PWD/activate.sh" >> ~/.bashrc
echo "source /proj/plasma/CODE/<username>/infra/activate.sh" >> ~/.bashrc

## External codes

Expand Down
1 change: 0 additions & 1 deletion SIMPLE
Submodule SIMPLE deleted from 8483ed
38 changes: 20 additions & 18 deletions activate.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
# Fish shell activation script
# Usage: source activate.fish

# Get the directory containing this script (absolute, without changing PWD)
# INFRA is this repository; CODE is the workspace one level up that holds it
# next to the code checkouts. The codes resolve dependencies as $CODE/<name>.
set SCRIPT_DIR (dirname (status --current-filename))
if type -q path
set -gx CODE (path resolve $SCRIPT_DIR)
set -gx INFRA (path resolve $SCRIPT_DIR)
else if type -q realpath
set -gx CODE (realpath $SCRIPT_DIR)
set -gx INFRA (realpath $SCRIPT_DIR)
else
# Fallback: temporarily cd and restore
set -l __oldpwd $PWD
cd $SCRIPT_DIR
set -gx CODE $PWD
set -gx INFRA $PWD
cd $__oldpwd
end
set -gx CODE (path resolve $INFRA/..)

echo "Setting CODE environment to: $CODE"
echo "Setting CODE workspace to: $CODE (infra: $INFRA)"

# Check if the OS is macOS
if test (uname) = "Darwin"
Expand Down Expand Up @@ -76,31 +78,31 @@ function set_branch_fish
else if test -n "$CI_COMMIT_REF_NAME"
set -gx CODE_BRANCH $CI_COMMIT_REF_NAME
else
# Avoid directory changes; query git directly in $CODE
set -gx CODE_BRANCH (git -C $CODE branch --show-current)
# Avoid directory changes; query git directly in $INFRA
set -gx CODE_BRANCH (git -C $INFRA branch --show-current)
if test -z "$CODE_BRANCH"
set -gx CODE_BRANCH (git -C $CODE rev-parse --short HEAD)
set -gx CODE_BRANCH (git -C $INFRA rev-parse --short HEAD)
end
end
echo "Activating $CODE on branch $CODE_BRANCH"
echo "Activating $INFRA on branch $CODE_BRANCH"
end

# Set up paths
set_branch_fish
add_to_path_fish $CODE/scripts
add_to_path_fish $CODE/local/bin
add_to_path_fish $CODE/bin
add_to_path_fish $INFRA/scripts
add_to_path_fish $INFRA/local/bin
add_to_path_fish $INFRA/bin

add_to_library_path_fish $CODE/libneo/build
add_to_library_path_fish $CODE/local/lib
add_to_library_path_fish $CODE/lib
add_to_library_path_fish $INFRA/local/lib
add_to_library_path_fish $INFRA/lib

# Activate Python virtual environment
if test -f $CODE/.venv/bin/activate.fish
source $CODE/.venv/bin/activate.fish
if test -f $INFRA/.venv/bin/activate.fish
source $INFRA/.venv/bin/activate.fish
else
echo "Warning: Python virtual environment fish activation script not found"
echo "Run: python -m venv $CODE/.venv to create it"
echo "Run: python -m venv $INFRA/.venv to create it"
end

# Load modules if available
Expand All @@ -115,6 +117,6 @@ if command -v code > /dev/null
alias vscode="code $CODE"
end

module use -a $CODE/modules
module use -a $INFRA/modules

echo "Fish shell activation complete!"
24 changes: 14 additions & 10 deletions activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ else
SCRIPT_SOURCE="$0"
fi

export CODE="$( cd "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
# INFRA is this repository. CODE is the workspace one level up that holds it
# next to the actual code checkouts (libneo, SIMPLE, ...). The codes resolve
# their dependencies as $CODE/<name> (find_or_fetch), so CODE is the parent.
export INFRA="$( cd "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
export CODE="$( cd "$INFRA/.." && pwd )"

# Check if the OS is macOS
if [ "$(uname)" = "Darwin" ]; then
Expand Down Expand Up @@ -86,22 +90,22 @@ if [ -n "$FISH_VERSION" ]; then
# Fish shell detected - redirect to dedicated fish script
echo "Fish shell detected!"
echo "Please use the dedicated fish script instead:"
echo " source $CODE/activate.fish"
echo " source $INFRA/activate.fish"
echo ""
echo "This script (activate.sh) is designed for bash/zsh compatibility."
return 1

else
# Bash/Zsh setup (original behavior)
source $CODE/scripts/util.sh
source $INFRA/scripts/util.sh
set_branch
add_to_path $CODE/scripts
add_to_path $CODE/local/bin
add_to_path $CODE/bin
add_to_path $INFRA/scripts
add_to_path $INFRA/local/bin
add_to_path $INFRA/bin
export PATH
add_to_library_path $CODE/libneo/build
add_to_library_path $CODE/local/lib
add_to_library_path $CODE/lib
add_to_library_path $INFRA/local/lib
add_to_library_path $INFRA/lib
if [ -n "$GSL_ROOT_DIR" ]; then
add_to_library_path $GSL_ROOT_DIR/lib
add_to_path $GSL_ROOT_DIR/bin
Expand All @@ -126,14 +130,14 @@ else
fi
export LD_LIBRARY_PATH

source $CODE/.venv/bin/activate
source $INFRA/.venv/bin/activate

if [ -f /etc/profile.d/modules.sh ]; then
unalias ml 2>/dev/null
source /etc/profile.d/modules.sh
fi

if command -v module >/dev/null 2>&1; then
module use -a $CODE/modules
module use -a $INFRA/modules
fi
fi
Loading