From ce22ceb0b8208218bfebe980c8d1ca1c180ffa5c Mon Sep 17 00:00:00 2001 From: Mayeul d'Avezac <2745737+mdavezac@users.noreply.github.com> Date: Tue, 26 May 2020 20:45:50 +0100 Subject: [PATCH] Adding codespace devcontainer --- .devcontainer/Dockerfile | 30 +++++++++++++++++++ .devcontainer/devcontainer.json | 41 ++++++++++++++++++++++++++ .devcontainer/symlinkDotNetCore.sh | 47 ++++++++++++++++++++++++++++++ .dockerignore | 3 ++ .gitignore | 2 +- setup.py | 1 + 6 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/symlinkDotNetCore.sh create mode 100644 .dockerignore diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..3e138db4 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,30 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# To fully customize the contents of this image, use the following Dockerfile instead: +# https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/codespaces-linux/.devcontainer/Dockerfile +FROM mcr.microsoft.com/vscode/devcontainers/universal:0-linux + +# ** [Optional] Uncomment this section to install additional packages. ** +# +ENV DEBIAN_FRONTEND=noninteractive +RUN sudo apt-get update \ + && sudo apt-get -y install --no-install-recommends \ + build-essential gfortran gcc g++ quantum-espresso \ + gfortran quantum-espresso quantum-espresso-data libopenmpi-dev \ + make git cmake ninja-build \ + # + # Clean up + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* +ARG pyver=3.6 +RUN /opt/python/${pyver}/bin/python -m venv /home/codespace/venv +RUN . /home/codespace/venv/bin/activate \ + && pip install --upgrade pip \ + && pip install setuptools wheel scikit-build "cmake!=3.16.3" ninja \ + && pip install cython numpy flake8 mypy black pytest \ + && pip install sphinx sphinx-autobuild rstcheck +ENV DEBIAN_FRONTEND=dialog diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..bdef3cb4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,41 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/codespaces-linux +{ + "name": "Codespaces", + "dockerFile": "Dockerfile", + "remoteUser": "codespace", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/codespace/workspace,type=bind,consistency=cached", + "workspaceFolder": "/home/codespace/workspace", + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vsonline.vsonline", + "GitHub.vscode-pull-request-github", + "MS-vsliveshare.vsliveshare", + "VisualStudioExptTeam.vscodeintellicode", + "ms-python.python", + "lextudio.restructuredtext", + "tcwalther.cython", + "twxs.cmake" + ], + // Set *default* container specific settings.json values on container create. + "settings": { + "python.formatting.provider": "black", + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.testing.pytestEnabled": true, + "python.pythonPath": "/home/codespace/venv/bin/python", + "python.venvFolders": [ + "venv" + ], + "cmake.cmakePath": "/home/codespace/venv/lib/python3.6/site-packages/cmake/data/bin/cmake" + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a" +} \ No newline at end of file diff --git a/.devcontainer/symlinkDotNetCore.sh b/.devcontainer/symlinkDotNetCore.sh new file mode 100644 index 00000000..dad6a920 --- /dev/null +++ b/.devcontainer/symlinkDotNetCore.sh @@ -0,0 +1,47 @@ +#!/nix/store/iqak4y6kxnjzz37idsffd2jha52wz31x-bash-4.4-p23/bin/bash +#-------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#-------------------------------------------------------------------------------------------------------------- + +set -ex + +splitSdksDir="/opt/dotnet/sdks" + +allSdksDir="/home/codespace/.dotnet" +mkdir -p "$allSdksDir" + +# Copy latest muxer and license files +cp -f "$splitSdksDir/3/dotnet" "$allSdksDir" +cp -f "$splitSdksDir/3/LICENSE.txt" "$allSdksDir" +cp -f "$splitSdksDir/3/ThirdPartyNotices.txt" "$allSdksDir" + +function createLinks() { + local sdkVersion="$1" + local runtimeVersion="$2" + + cd "$splitSdksDir/$sdkVersion" + + # Find folders with name as sdk or runtime version + find . -name "$sdkVersion" -o -name "$runtimeVersion" | while read subPath; do + # Trim beginning 2 characters from the line which currently looks like, for example, './sdk/2.2.402' + subPath="${subPath:2}" + + linkFrom="$allSdksDir/$subPath" + linkFromParentDir=$(dirname $linkFrom) + mkdir -p "$linkFromParentDir" + + linkTo="$splitSdksDir/$sdkVersion/$subPath" + ln -s $linkTo $linkFrom + done +} + +createLinks "3.1.201" "3.1.3" +echo +createLinks "3.0.103" "3.0.3" +echo +createLinks "2.2.402" "2.2.7" +echo +createLinks "2.1.805" "2.1.17" +echo +createLinks "1.1.14" "1.1.13" \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..fb527b75 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.venv/ +.direnv/ +_skbuild/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2dc13637..b824340e 100644 --- a/.gitignore +++ b/.gitignore @@ -146,4 +146,4 @@ shell.nix .local/ .vim/ .direnv/ -.clang +.clang \ No newline at end of file diff --git a/setup.py b/setup.py index 3a4c2b00..694ecd78 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ def wrapped_setup(*args, **kwargs): "nbformat", "ipykernel", "IPython", + "black", ] if version_info[0] == 2: tests_require.append("mock")