diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index 7c5d009260c64..0000000000000 --- a/.devcontainer.json +++ /dev/null @@ -1,29 +0,0 @@ -// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at -// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3-miniconda -{ - "name": "pandas", - "context": ".", - "dockerFile": "Dockerfile", - - // Use 'settings' to set *default* container specific settings.json values on container create. - // You can edit these settings after create using File > Preferences > Settings > Remote. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "python.pythonPath": "/usr/local/bin/python", - "python.formatting.provider": "black", - "python.linting.enabled": true, - "python.linting.flake8Enabled": true, - "python.linting.pylintEnabled": false, - "python.linting.mypyEnabled": true, - "python.testing.pytestEnabled": true, - "python.testing.pytestArgs": [ - "pandas" - ] - }, - - // Add the IDs of extensions you want installed when the container is created in the array below. - "extensions": [ - "ms-python.python", - "ms-vscode.cpptools" - ] -} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000000..f0a249cf396fd --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,64 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at +// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3-miniconda +{ + "name": "pandas", + "containerUser": "pandas-dev", + "context": "..", + "dockerFile": "../Dockerfile", + "postCreateCommand": "./.devcontainer/postCreateCommand.sh", + // Use `customizations/vscode/settings` to set *default* container specific + // settings.json values on container create. You can edit these settings + // after create using File > Preferences > Settings > Remote. + "customizations": { + "vscode": { + // Add the IDs of extensions you want installed when the + // container is created in the array below. + "extensions": [ + "ms-python.python", + "ms-python.black-formatter", + "ms-python.flake8", + "ms-python.mypy-type-checker", + "ms-python.pylint", + "ms-vscode.cpptools", + "ms-azuretools.vscode-docker", + "GitHub.vscode-github-actions" + ], + "settings": { + // Editor configuration: + "editor.detectIndentation": false, + "editor.formatOnSave": true, + "editor.insertSpaces": true, + "editor.rulers": [ + 88 + ], + "editor.tabSize": 4, + "files.insertFinalNewline": true, + // Python tooling: + "black-formatter.importStrategy": "fromEnvironment", + "flake8.args": [ + "--max-line-length=88" + ], + "flake8.importStrategy": "fromEnvironment", + "mypy-type-checker.importStrategy": "fromEnvironment", + "mypy-type-checker.showNotifications": "always", + "pylint.args": [ + "--load-plugins=pylint.extensions.redefined_loop_name" + ], + "pylint.importStrategy": "fromEnvironment", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.analysis.typeCheckingMode": "basic", + "python.linting.mypyEnabled": true, // Deprecated, but seemingly required to get VSCode to display mypy diagnostics + "python.testing.pytestArgs": [ + "pandas" + ], + "python.testing.pytestEnabled": true, + // Environment and terminal configuration: + "python.defaultInterpreterPath": "/home/pandas-dev/micromamba/envs/test/bin/python", + "python.terminal.activateEnvironment": false, + "terminal.integrated.defaultProfile.linux": "bash" + } + } + } +} diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100755 index 0000000000000..8fc0ed07a8194 --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -0,0 +1,45 @@ +#! /usr/bin/env bash + +set -e + +~/micromamba-bin/micromamba \ + create \ + -y \ + -r ~/micromamba \ + -f environment.yml \ + -n test \ + --rc-file ci/condarc.yml + +mv ~/.bashrc ~/.bashrc.orig +~/micromamba-bin/micromamba shell init --shell bash --root-prefix=~/micromamba +mv ~/.bashrc ~/.mamba-bashrc +cp ~/.bashrc.orig ~/.bashrc +echo micromamba activate test >> ~/.mamba-bashrc +cat ~/.mamba-bashrc >> ~/.bashrc +cat ~/.mamba-bashrc >> ~/.bash_profile +source ~/.mamba-bashrc + + +if [[ $(git tag | wc -c) -eq 0 ]] +then + echo -e '\n\nERROR:' + echo Your repository has been cloned without tags. + echo To fix this, add the original pandas GitHub repository as an upstream + echo reference, e.g., via the following: + echo git remote add upstream https://github.com/pandas-dev/pandas.git + echo Then, run + echo git fetch --tags upstream + echo to get the main repository\'s tags, and optionally run + echo git push --tags + echo to upload the tags to your GitHub fork. + echo + echo Finally, rebuild the devcontainer. + exit 1 +fi + +pip install black + +pip uninstall -y pandas +pip install -e . --no-build-isolation -v + +pre-commit install diff --git a/Dockerfile b/Dockerfile index 7230dcab20f6e..a32c09f4b1995 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,21 @@ RUN apt-get install -y build-essential # hdf5 needed for pytables installation RUN apt-get install -y libhdf5-dev -RUN python -m pip install --upgrade pip -RUN python -m pip install \ - -r https://raw.githubusercontent.com/pandas-dev/pandas/main/requirements-dev.txt +RUN apt-get install -y vim less + +ARG USERNAME=pandas-dev +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +RUN apt-get install -y curl bzip2 && sudo -u $USERNAME bash -c \ + "mkdir ~/bin && \ + curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | \ + tar -C ~ -xj bin/micromamba \ + && mv ~/bin ~/micromamba-bin" + CMD ["/bin/bash"] diff --git a/doc/source/development/contributing_environment.rst b/doc/source/development/contributing_environment.rst index 0cc1fe2629e46..9b09810397d3d 100644 --- a/doc/source/development/contributing_environment.rst +++ b/doc/source/development/contributing_environment.rst @@ -184,7 +184,7 @@ Run Container:: **Visual Studio Code** You can use the DockerFile to launch a remote session with Visual Studio Code, -a popular free IDE, using the ``.devcontainer.json`` file. +a popular free IDE, using the ``.devcontainer`` directory. See https://code.visualstudio.com/docs/remote/containers for details. **PyCharm (Professional)**