From 5b82b995a6cc394c0deb762ffe630917e3cff58c Mon Sep 17 00:00:00 2001
From: "Xuefeng Ding (IHEP)" <dingxf@ihep.ac.cn>
Date: Thu, 5 Dec 2024 14:31:41 +0000
Subject: [PATCH] update dockefile and folder

---
 .devcontainer/install_zsh.sh                  |  75 ------------------
 .devcontainer/non-root-user/Dockerfile        |  66 ++++++++-------
 .devcontainer/non-root-user/devcontainer.json |  16 +++-
 .devcontainer/root-user/Dockerfile            |  45 +++++------
 .devcontainer/root-user/devcontainer.json     |   1 +
 .vscode/settings.json                         |  18 ++++-
 {cpp => cxx}/CMakeLists.txt                   |   0
 {cpp => cxx}/include/complexf.h               |   0
 {cpp => cxx}/include/hello.h                  |   0
 {cpp => cxx}/src/complexf.cc                  |   0
 {cpp => cxx}/src/hello.cc                     |   0
 {python => src}/myproj/simulation/__init__.py |   0
 .../myproj/simulation/_csrc/CMakeLists.txt    |   0
 .../_hello.cpython-310-x86_64-linux-gnu.so    | Bin
 .../myproj/simulation/_csrc/_hello.pyi        |   0
 .../myproj/simulation/_csrc/_hello_python.cc  |   0
 .../myproj/simulation/_csrc/libcomplexf.so    | Bin
 .../myproj/simulation/_csrc/libhello.so       | Bin
 {python => src}/myproj/simulation/core.py     |   0
 {python => src}/myproj/simulation/py.typed    |   0
 {python => src}/tests/test_simulation.py      |   1 +
 21 files changed, 94 insertions(+), 128 deletions(-)
 delete mode 100755 .devcontainer/install_zsh.sh
 rename {cpp => cxx}/CMakeLists.txt (100%)
 rename {cpp => cxx}/include/complexf.h (100%)
 rename {cpp => cxx}/include/hello.h (100%)
 rename {cpp => cxx}/src/complexf.cc (100%)
 rename {cpp => cxx}/src/hello.cc (100%)
 rename {python => src}/myproj/simulation/__init__.py (100%)
 rename {python => src}/myproj/simulation/_csrc/CMakeLists.txt (100%)
 rename {python => src}/myproj/simulation/_csrc/_hello.cpython-310-x86_64-linux-gnu.so (100%)
 rename {python => src}/myproj/simulation/_csrc/_hello.pyi (100%)
 rename {python => src}/myproj/simulation/_csrc/_hello_python.cc (100%)
 rename {python => src}/myproj/simulation/_csrc/libcomplexf.so (100%)
 rename {python => src}/myproj/simulation/_csrc/libhello.so (100%)
 rename {python => src}/myproj/simulation/core.py (100%)
 rename {python => src}/myproj/simulation/py.typed (100%)
 rename {python => src}/tests/test_simulation.py (99%)

diff --git a/.devcontainer/install_zsh.sh b/.devcontainer/install_zsh.sh
deleted file mode 100755
index bc2f433..0000000
--- a/.devcontainer/install_zsh.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env bash
-#-------------------------------------------------------------------------------------------------------------
-# Copyright (c) Microsoft Corporation. All rights reserved.
-# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
-#-------------------------------------------------------------------------------------------------------------
-#
-# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md
-# Maintainer: The VS Code and Codespaces Teams
-#
-# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages]
-
-set -e
-
-INSTALL_ZSH="true"
-USERNAME=$(whoami)
-INSTALL_OH_MYS="true"
-
-# ** Shell customization section **
-if [ "${USERNAME}" = "root" ]; then
-    user_rc_path="/root"
-else
-    user_rc_path="/home/${USERNAME}"
-fi
-
-codespaces_zsh="$(cat \
-<<'EOF'
-# Codespaces zsh prompt theme
-__zsh_prompt() {
-    local prompt_username
-    if [ ! -z "${GITHUB_USER}" ]; then
-        prompt_username="@${GITHUB_USER}"
-    else
-        prompt_username="%n"
-    fi
-    PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}鉃� :%{$fg_bold[red]%}鉃� )" # User/exit code arrow
-    PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/鈥�/%3~|%4~)%{$reset_color%} ' # cwd
-    PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status
-    PROMPT+='%{$fg[white]%}$ %{$reset_color%}'
-    unset -f __zsh_prompt
-}
-ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}"
-ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
-ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}鉁�%{$fg_bold[cyan]%})"
-ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})"
-__zsh_prompt
-
-EOF
-)"
-
-# Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme.
-# See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script.
-oh_my_install_dir="${user_rc_path}/.oh-my-zsh"
-template_path="${oh_my_install_dir}/templates/zshrc.zsh-template"
-user_rc_file="${user_rc_path}/.zshrc"
-if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then
-    umask g-w,o-w
-    mkdir -p ${oh_my_install_dir}
-    git clone --depth=1 \
-        -c core.eol=lf \
-        -c core.autocrlf=false \
-        -c fsck.zeroPaddedFilemode=ignore \
-        -c fetch.fsck.zeroPaddedFilemode=ignore \
-        -c receive.fsck.zeroPaddedFilemode=ignore \
-        "https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git" "${oh_my_install_dir}" 2>&1
-
-    mkdir -p ${oh_my_install_dir}/custom/themes
-    echo "${codespaces_zsh}" > "${oh_my_install_dir}/custom/themes/codespaces.zsh-theme"
-    # Shrink git while still enabling updates
-    cd "${oh_my_install_dir}"
-    git repack -a -d -f --depth=1 --window=1
-fi
-echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
-sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file}
-
-echo "Done!"
diff --git a/.devcontainer/non-root-user/Dockerfile b/.devcontainer/non-root-user/Dockerfile
index db0867d..80df6d2 100644
--- a/.devcontainer/non-root-user/Dockerfile
+++ b/.devcontainer/non-root-user/Dockerfile
@@ -1,38 +1,48 @@
 # Use AlmaLinux 9 base image
 FROM almalinux:9
-
-RUN useradd -m vscode
-
-RUN dnf --best --assumeyes update \
-    && dnf -y install \
-    python3.11 \
-    python3.11-pip \
-    gcc \
-    make \
-    cmake \
-    git \
-    zsh \
-    which \
-    util-linux-user \
-    && dnf clean all \
-    && chsh -s /bin/zsh vscode
-
+LABEL user.name="vscode"
+
+# https://apt.llvm.org/
+RUN dnf --best --assumeyes update && \
+    dnf -y install \
+        python3.11 python3.11-pip \
+        gcc make cmake \
+        git \
+        zsh \
+        which util-linux-user wget sudo passwd \
+        clang lldb lld clang-tools-extra && \
+    dnf clean all
+
+RUN rm /usr/bin/cc /usr/bin/c++ && \
+    alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
+    alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 && \
+    alternatives --auto c++ && \
+    alternatives --auto cc
+
+RUN dnf -y install 'dnf-command(config-manager)' && \
+    dnf -y config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo && \
+    dnf -y install cuda-nvcc-12-4 && \
+    dnf clean all
+
+RUN useradd -ms /bin/zsh vscode && \
+    usermod -aG wheel vscode
 
 WORKDIR /workspaces
 USER vscode
 
-RUN python3.11 -m venv /workspaces/.venv
+RUN python3.11 -m venv /workspaces/venv
 
 COPY requirements.txt /workspaces/requirements.txt
 COPY requirements-dev.txt /workspaces/requirements-dev.txt
-COPY .devcontainer/install_zsh.sh /workspaces/install_zsh.sh
-
-RUN /workspaces/install_zsh.sh
-
-RUN echo 'source /workspaces/.venv/bin/activate' >> ~/.zshrc \
-    && source /workspaces/.venv/bin/activate \
-    && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
-    && pip install --upgrade pip \
-    && pip install -r requirements-dev.txt
 
-RUN rm -rf /workspaces/requirements.txt /workspaces/requirements-dev.txt /workspaces/install_zsh.sh
+RUN sh -c "$(curl -fsSL https://install.ohmyz.sh/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
+
+RUN echo 'export PATH="/usr/local/cuda-12.4/bin${PATH:+:${PATH}}"' >>~/.zshrc && \
+    echo 'export LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"' >>~/.zshrc && \
+    source /workspaces/venv/bin/activate && \
+    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
+    pip install --upgrade pip && \
+    pip install -r requirements-dev.txt && \
+    rm -rf /workspaces/requirements.txt /workspaces/requirements-dev.txt && \
+    echo "hi"
+    # sudo chown vscode:vscode -R /workspaces
diff --git a/.devcontainer/non-root-user/devcontainer.json b/.devcontainer/non-root-user/devcontainer.json
index d1b86f8..8d98e5d 100644
--- a/.devcontainer/non-root-user/devcontainer.json
+++ b/.devcontainer/non-root-user/devcontainer.json
@@ -5,5 +5,19 @@
     "context": "../.."
   },
   "runArgs": ["--userns=keep-id"], // needed for podman
-  "remoteUser": "vscode"
+  "remoteUser": "vscode",
+  "postCreateCommand": "",
+  "customizations": {
+    "vscode": {
+      "extensions": [
+        "llvm-vs-code-extensions.vscode-clangd",
+        "vadimcn.vscode-lldb",
+        "ms-toolsai.jupyter",
+        "ziruiwang.nvidia-monitor",
+        "esbenp.prettier-vscode",
+        "ms-python.python",
+        "charliermarsh.ruff"
+      ]
+    }
+  }
 }
diff --git a/.devcontainer/root-user/Dockerfile b/.devcontainer/root-user/Dockerfile
index d3e9f91..1696ea5 100644
--- a/.devcontainer/root-user/Dockerfile
+++ b/.devcontainer/root-user/Dockerfile
@@ -1,35 +1,34 @@
 # Use AlmaLinux 9 base image
 FROM almalinux:9
+LABEL user.name="root"
 
 WORKDIR /workspaces
 
-RUN dnf --best --assumeyes update \
-    && dnf -y install \
-    python3.11 \
-    python3.11-pip \
-    gcc \
-    make \
-    cmake \
-    git \
-    zsh \
-    which \
-    util-linux-user \
-    && dnf clean all \
-    && chsh -s /bin/zsh root
-
-RUN python3.11 -m venv /workspaces/.venv
+RUN dnf --best --assumeyes update && \
+    dnf -y install \
+        python3.11 \
+        python3.11-pip \
+        gcc \
+        make \
+        cmake \
+        git \
+        zsh \
+        which \
+        util-linux-user && \
+    dnf clean all && \
+    chsh -s /bin/zsh root
+
+RUN python3.11 -m venv /workspaces/venv
 
 COPY requirements.txt /workspaces/requirements.txt
 COPY requirements-dev.txt /workspaces/requirements-dev.txt
-COPY .devcontainer/install_zsh.sh /workspaces/install_zsh.sh
-
-RUN /workspaces/install_zsh.sh
 
-RUN echo 'source /workspaces/.venv/bin/activate' >> ~/.zshrc \
-    && source /workspaces/.venv/bin/activate \
-    && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
-    && pip install --upgrade pip \
-    && pip install -r requirements-dev.txt
+RUN sh -c "$(curl -fsSL https://install.ohmyz.sh/install.sh)" "" --unattended
 
+RUN source /workspaces/venv/bin/activate && \
+    echo 'source /workspaces/venv/bin/activate' >> ~/.zshrc && \
+    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
+    pip install --upgrade pip && \
+    pip install -r requirements-dev.txt
 
 RUN rm -rf /workspaces/requirements.txt /workspaces/requirements-dev.txt /workspaces/install_zsh.sh
diff --git a/.devcontainer/root-user/devcontainer.json b/.devcontainer/root-user/devcontainer.json
index 882b69a..4cc86a3 100644
--- a/.devcontainer/root-user/devcontainer.json
+++ b/.devcontainer/root-user/devcontainer.json
@@ -1,4 +1,5 @@
 {
+  // example how to make a devcontainer for root user
   "name": "Alma9 (root)",
   "build": {
     "dockerfile": "./Dockerfile",
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 31a1f06..d1c34ab 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -53,6 +53,22 @@
   "python.analysis.inlayHints.variableTypes": true,
   "python.analysis.typeCheckingMode": "strict",
   "python.analysis.extraPaths": ["${workspaceFolder}/python"],
+  "[shellscript]": {
+    "editor.defaultFormatter": "foxundermoon.shell-format"
+  },
   // "docker.host": "unix:///run/user/1000/podman/podman.sock"
-  "dev.containers.dockerPath": "podman"
+  "dev.containers.dockerPath": "podman",
+  "shellformat.effectLanguages": [
+    "shellscript",
+    // "dockerfile",
+    "dotenv",
+    "hosts",
+    "jvmoptions",
+    "ignore",
+    "gitignore",
+    "properties",
+    "spring-boot-properties",
+    "azcli",
+    "bats"
+  ]
 }
diff --git a/cpp/CMakeLists.txt b/cxx/CMakeLists.txt
similarity index 100%
rename from cpp/CMakeLists.txt
rename to cxx/CMakeLists.txt
diff --git a/cpp/include/complexf.h b/cxx/include/complexf.h
similarity index 100%
rename from cpp/include/complexf.h
rename to cxx/include/complexf.h
diff --git a/cpp/include/hello.h b/cxx/include/hello.h
similarity index 100%
rename from cpp/include/hello.h
rename to cxx/include/hello.h
diff --git a/cpp/src/complexf.cc b/cxx/src/complexf.cc
similarity index 100%
rename from cpp/src/complexf.cc
rename to cxx/src/complexf.cc
diff --git a/cpp/src/hello.cc b/cxx/src/hello.cc
similarity index 100%
rename from cpp/src/hello.cc
rename to cxx/src/hello.cc
diff --git a/python/myproj/simulation/__init__.py b/src/myproj/simulation/__init__.py
similarity index 100%
rename from python/myproj/simulation/__init__.py
rename to src/myproj/simulation/__init__.py
diff --git a/python/myproj/simulation/_csrc/CMakeLists.txt b/src/myproj/simulation/_csrc/CMakeLists.txt
similarity index 100%
rename from python/myproj/simulation/_csrc/CMakeLists.txt
rename to src/myproj/simulation/_csrc/CMakeLists.txt
diff --git a/python/myproj/simulation/_csrc/_hello.cpython-310-x86_64-linux-gnu.so b/src/myproj/simulation/_csrc/_hello.cpython-310-x86_64-linux-gnu.so
similarity index 100%
rename from python/myproj/simulation/_csrc/_hello.cpython-310-x86_64-linux-gnu.so
rename to src/myproj/simulation/_csrc/_hello.cpython-310-x86_64-linux-gnu.so
diff --git a/python/myproj/simulation/_csrc/_hello.pyi b/src/myproj/simulation/_csrc/_hello.pyi
similarity index 100%
rename from python/myproj/simulation/_csrc/_hello.pyi
rename to src/myproj/simulation/_csrc/_hello.pyi
diff --git a/python/myproj/simulation/_csrc/_hello_python.cc b/src/myproj/simulation/_csrc/_hello_python.cc
similarity index 100%
rename from python/myproj/simulation/_csrc/_hello_python.cc
rename to src/myproj/simulation/_csrc/_hello_python.cc
diff --git a/python/myproj/simulation/_csrc/libcomplexf.so b/src/myproj/simulation/_csrc/libcomplexf.so
similarity index 100%
rename from python/myproj/simulation/_csrc/libcomplexf.so
rename to src/myproj/simulation/_csrc/libcomplexf.so
diff --git a/python/myproj/simulation/_csrc/libhello.so b/src/myproj/simulation/_csrc/libhello.so
similarity index 100%
rename from python/myproj/simulation/_csrc/libhello.so
rename to src/myproj/simulation/_csrc/libhello.so
diff --git a/python/myproj/simulation/core.py b/src/myproj/simulation/core.py
similarity index 100%
rename from python/myproj/simulation/core.py
rename to src/myproj/simulation/core.py
diff --git a/python/myproj/simulation/py.typed b/src/myproj/simulation/py.typed
similarity index 100%
rename from python/myproj/simulation/py.typed
rename to src/myproj/simulation/py.typed
diff --git a/python/tests/test_simulation.py b/src/tests/test_simulation.py
similarity index 99%
rename from python/tests/test_simulation.py
rename to src/tests/test_simulation.py
index 52919f5..3f5fb53 100644
--- a/python/tests/test_simulation.py
+++ b/src/tests/test_simulation.py
@@ -14,6 +14,7 @@
 #  All rights reserved. 2024 copyrighted.
 #############################################################################
 import pytest
+
 from myproj.simulation import add, complexf
 
 
-- 
GitLab