diff --git a/.devcontainer/install_zsh.sh b/.devcontainer/install_zsh.sh deleted file mode 100755 index bc2f433aebf7a4ba87effdec3cc9086f439911c7..0000000000000000000000000000000000000000 --- 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 db0867da2aeb37e8be37b45fb3154fe6b90ad8df..80df6d25baea0c7c2c5fd31e6727a814060cba72 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 d1b86f8767d68b5c78e712745e451b7948dcc727..8d98e5dc7681d403f220a8e5529dc24d0518eea8 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 d3e9f917dd008c4bc31e3edc66662568b683513a..1696ea5f7d67364aa0c0cb045acff44dd124f8ce 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 882b69abcf524003fdeec7ebc111df33d1e1e913..4cc86a3455f92e487ef811947f1e5fe1481f190b 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 31a1f0644985fd989cae61445c8524d6352ecdb3..d1c34ab1da32839e1df9deb71734e95fc5725d60 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 52919f541c7afab674f094b12fbe29f01d94c27e..3f5fb53619871a8893182a6d1b72da95c3bd5f02 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