Skip to content

ENH: Bring devcontainer closer to GitHub CI environment, improve vscode setup #54845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
624c446
Move `.devcontainer.json`, adapt paths accordingly.
DavidToneian Jul 6, 2023
34453bb
Adapt `devcontainer.json` to use recommended container settings inste…
DavidToneian Jul 15, 2023
2326b39
Remove `python.pythonPath` VSCode setting to let the default be picke…
DavidToneian Jul 16, 2023
780a336
Set defaults for `devcontainer` Visual Studio Code IDE to indent with…
DavidToneian Jul 15, 2023
c3cd0cb
Make `devcontainer` use non-root user.
DavidToneian Jul 16, 2023
76065b9
Merge branch 'main' into micromamba-in-devcontainer
DavidToneian Aug 18, 2023
a6cb330
Fix: add trailing newline to devcontainer.json
DavidToneian Aug 19, 2023
1d11475
WIP: Modernize `.devcontainer`.
DavidToneian Aug 28, 2023
4676121
Clean up `devcontainer.json`.
DavidToneian Aug 29, 2023
40fe95e
Order settings in `devcontainer.json`.
DavidToneian Aug 29, 2023
eb8569a
Fix vscode python tool integrations, avoid attempt to use conda.
DavidToneian Aug 29, 2023
6947fb3
Improve organization of settings in `devcontainer.json`.
DavidToneian Aug 29, 2023
551bfe8
Align maximum line length in vscode with `pyproject.toml`.
DavidToneian Aug 29, 2023
2b6c6f7
Install `black` in devcontainer to support automatic formatting.
DavidToneian Aug 29, 2023
f8edf5b
Load the `pylint` `redefined_loop_name` extension to avoid a warning …
DavidToneian Aug 29, 2023
99593c2
Improve error message on missing tags.
DavidToneian Aug 29, 2023
5cbfa4c
Make mypy work in VSCode.
DavidToneian Aug 29, 2023
1e1df70
Do not build docs in `postCreateCommand.sh`.
DavidToneian Aug 29, 2023
a6ea0c2
Install `micromamba` in `Dockerfile`.
DavidToneian Aug 29, 2023
0bcf57c
Merge branch 'main' into micromamba-in-devcontainer
DavidToneian Aug 29, 2023
4f3cca4
Update docs for `devcontainer`.
DavidToneian Aug 29, 2023
9468b1f
Add final newline to `devcontainer.json`, and make sure it stays.
DavidToneian Aug 29, 2023
e520dfd
Install pre-commit hooks in `devcontainer`.
DavidToneian Aug 29, 2023
1b26a50
Install `less` in `devcontainer`.
DavidToneian Aug 29, 2023
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
29 changes: 0 additions & 29 deletions .devcontainer.json

This file was deleted.

64 changes: 64 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
45 changes: 45 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 17 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion doc/source/development/contributing_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand Down