Skip to content

Commit 39e0964

Browse files
DEV: Add gitpod configuration files (#48107)
Co-authored-by: Joris Van den Bossche <[email protected]>
1 parent 7f47d33 commit 39e0964

File tree

5 files changed

+264
-0
lines changed

5 files changed

+264
-0
lines changed

.gitpod.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Building pandas on init
2+
# Might delegate this later to prebuild with Q2 improvements on gitpod
3+
# https://www.gitpod.io/docs/config-start-tasks/#configuring-the-terminal
4+
# -------------------------------------------------------------------------
5+
6+
# assuming we use dockerhub: name of the docker user, docker image, tag, e.g. https://hub.docker.com/r/pandas/pandas-gitpod/tags
7+
image: pythonpandas/pandas-gitpod:latest
8+
tasks:
9+
- name: Prepare development environment
10+
init: |
11+
mkdir -p .vscode
12+
cp gitpod/settings.json .vscode/settings.json
13+
conda activate pandas-dev
14+
git pull --unshallow # need to force this else the prebuild fails
15+
git fetch --tags
16+
python setup.py build_ext -j 4
17+
python -m pip install -e . --no-build-isolation
18+
echo "🛠 Completed rebuilding Pandas!! 🛠 "
19+
echo "✨ Pre-build complete! You can close this terminal ✨ "
20+
21+
# --------------------------------------------------------
22+
# exposing ports for liveserve
23+
ports:
24+
- port: 5500
25+
onOpen: notify
26+
27+
# --------------------------------------------------------
28+
# some useful extensions to have
29+
vscode:
30+
extensions:
31+
- ms-python.python
32+
- yzhang.markdown-all-in-one
33+
- eamodio.gitlens
34+
- lextudio.restructuredtext
35+
# add or remove what you think is generally useful to most contributors
36+
# avoid adding too many. they each open a pop-up window
37+
38+
# --------------------------------------------------------
39+
# using prebuilds for the container
40+
# With this configuration the prebuild will happen on push to main
41+
github:
42+
prebuilds:
43+
# enable for main/default branch
44+
main: true
45+
# enable for other branches (defaults to false)
46+
branches: false
47+
# enable for pull requests coming from this repo (defaults to true)
48+
pullRequests: false
49+
# enable for pull requests coming from forks (defaults to false)
50+
pullRequestsFromForks: false
51+
# add a check to pull requests (defaults to true)
52+
addCheck: false
53+
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
54+
addComment: false
55+
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
56+
addBadge: false
57+
# add a label once the prebuild is ready to pull requests (defaults to false)
58+
addLabel: false

gitpod/Dockerfile

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#
2+
# Dockerfile for pandas development
3+
#
4+
# Usage:
5+
# -------
6+
#
7+
# To make a local build of the container, from the 'Docker-dev' directory:
8+
# docker build --rm -f "Dockerfile" -t <build-tag> "."
9+
#
10+
# To use the container use the following command. It assumes that you are in
11+
# the root folder of the pandas git repository, making it available as
12+
# /home/pandas in the container. Whatever changes you make to that directory
13+
# are visible in the host and container.
14+
# The docker image is retrieved from the pandas dockerhub repository
15+
#
16+
# docker run --rm -it -v $(pwd):/home/pandas pandas/pandas-dev:<image-tag>
17+
#
18+
# By default the container will activate the conda environment pandas-dev
19+
# which contains all the dependencies needed for pandas development
20+
#
21+
# To build and install pandas run:
22+
# python setup.py build_ext -j 4
23+
# python -m pip install -e . --no-build-isolation
24+
#
25+
# This image is based on: Ubuntu 20.04 (focal)
26+
# https://hub.docker.com/_/ubuntu/?tab=tags&name=focal
27+
# OS/ARCH: linux/amd64
28+
FROM gitpod/workspace-base:latest
29+
30+
ARG MAMBAFORGE_VERSION="22.9.0-1"
31+
ARG CONDA_ENV=pandas-dev
32+
ARG PANDAS_HOME="/home/pandas"
33+
34+
35+
# ---- Configure environment ----
36+
ENV CONDA_DIR=/home/gitpod/mambaforge3 \
37+
SHELL=/bin/bash
38+
ENV PATH=${CONDA_DIR}/bin:$PATH \
39+
WORKSPACE=/workspace/pandas
40+
41+
# -----------------------------------------------------------------------------
42+
# ---- Creating as root - note: make sure to change to gitpod in the end ----
43+
USER root
44+
45+
# Avoid warnings by switching to noninteractive
46+
ENV DEBIAN_FRONTEND=noninteractive
47+
48+
# Configure apt and install packages
49+
RUN apt-get update \
50+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
51+
#
52+
# Install tzdata and configure timezone (fix for tests which try to read from "/etc/localtime")
53+
&& apt-get -y install tzdata \
54+
&& ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \
55+
&& dpkg-reconfigure -f noninteractive tzdata \
56+
#
57+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
58+
&& apt-get -y install git iproute2 procps iproute2 lsb-release \
59+
#
60+
# cleanup
61+
&& apt-get autoremove -y \
62+
&& apt-get clean -y \
63+
&& rm -rf /var/lib/apt/lists/*
64+
65+
# Switch back to dialog for any ad-hoc use of apt-get
66+
ENV DEBIAN_FRONTEND=dialog
67+
68+
# Allows this Dockerfile to activate conda environments
69+
SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
70+
71+
# -----------------------------------------------------------------------------
72+
# ---- Installing mamba ----
73+
RUN wget -q -O mambaforge3.sh \
74+
"https://github.com/conda-forge/miniforge/releases/download/$MAMBAFORGE_VERSION/Mambaforge-$MAMBAFORGE_VERSION-Linux-x86_64.sh" && \
75+
bash mambaforge3.sh -p ${CONDA_DIR} -b && \
76+
rm mambaforge3.sh
77+
78+
# -----------------------------------------------------------------------------
79+
# ---- Copy needed files ----
80+
# basic workspace configurations
81+
COPY ./gitpod/workspace_config /usr/local/bin/workspace_config
82+
83+
RUN chmod a+rx /usr/local/bin/workspace_config && \
84+
workspace_config
85+
86+
# the container to create a conda environment from it
87+
COPY environment.yml /tmp/environment.yml
88+
89+
RUN mamba env create -f /tmp/environment.yml
90+
# ---- Create conda environment ----
91+
RUN conda activate $CONDA_ENV && \
92+
mamba install ccache -y && \
93+
# needed for docs rendering later on
94+
python -m pip install --no-cache-dir sphinx-autobuild && \
95+
conda clean --all -f -y && \
96+
rm -rf /tmp/*
97+
98+
# -----------------------------------------------------------------------------
99+
# Always make sure we are not root
100+
USER gitpod

gitpod/gitpod.Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Doing a local shallow clone - keeps the container secure
2+
# and much slimmer than using COPY directly or making a
3+
# remote clone
4+
ARG BASE_CONTAINER="pythonpandas/pandas-dev:latest"
5+
FROM gitpod/workspace-base:latest as clone
6+
7+
# the clone should be deep enough for versioneer to work
8+
RUN git clone https://github.com/pandas-dev/pandas --depth 12 /tmp/pandas
9+
10+
# -----------------------------------------------------------------------------
11+
# Using the pandas-dev Docker image as a base
12+
# This way, we ensure we have all the needed compilers and dependencies
13+
# while reducing the build time
14+
FROM ${BASE_CONTAINER} as build
15+
16+
# -----------------------------------------------------------------------------
17+
USER root
18+
19+
# -----------------------------------------------------------------------------
20+
# ---- ENV variables ----
21+
# ---- Directories needed ----
22+
ENV WORKSPACE=/workspace/pandas/ \
23+
CONDA_ENV=pandas-dev
24+
25+
# Allows this micromamba.Dockerfile to activate conda environments
26+
SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
27+
28+
# Copy over the shallow clone
29+
COPY --from=clone --chown=gitpod /tmp/pandas ${WORKSPACE}
30+
31+
# Everything happens in the /workspace/pandas directory
32+
WORKDIR ${WORKSPACE}
33+
34+
# Build pandas to populate the cache used by ccache
35+
RUN git config --global --add safe.directory /workspace/pandas
36+
RUN conda activate ${CONDA_ENV} && \
37+
python setup.py build_ext --inplace && \
38+
ccache -s
39+
40+
# Gitpod will load the repository into /workspace/pandas. We remove the
41+
# directory from the image to prevent conflicts
42+
RUN rm -rf ${WORKSPACE}
43+
44+
# -----------------------------------------------------------------------------
45+
# Always return to non privileged user
46+
USER gitpod

gitpod/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"restructuredtext.updateOnTextChanged": "true",
3+
"restructuredtext.updateDelay": 300,
4+
"restructuredtext.linter.disabledLinters": ["doc8","rst-lint", "rstcheck"],
5+
"python.defaultInterpreterPath": "/home/gitpod/mambaforge3/envs/pandas-dev/bin/python"
6+
}

gitpod/workspace_config

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# Basic configurations for the workspace
3+
4+
set -e
5+
6+
# gitpod/workspace-base needs at least one file here
7+
touch /home/gitpod/.bashrc.d/empty
8+
9+
# Add git aliases
10+
git config --global alias.co checkout
11+
git config --global alias.ci commit
12+
git config --global alias.st status
13+
git config --global alias.br branch
14+
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
15+
git config --global alias.type 'cat-file -t'
16+
git config --global alias.dump 'cat-file -p'
17+
18+
# Enable basic vim defaults in ~/.vimrc
19+
echo "filetype plugin indent on" >>~/.vimrc
20+
echo "set colorcolumn=80" >>~/.vimrc
21+
echo "set number" >>~/.vimrc
22+
echo "syntax enable" >>~/.vimrc
23+
24+
# Vanity custom bash prompt - makes it more legible
25+
echo "PS1='\[\e]0;\u \w\a\]\[\033[01;36m\]\u\[\033[m\] > \[\033[38;5;141m\]\w\[\033[m\] \\$ '" >>~/.bashrc
26+
27+
# Enable prompt color in the skeleton .bashrc
28+
# hadolint ignore=SC2016
29+
sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
30+
31+
# .gitpod.yml is configured to install pandas from /workspace/pandas
32+
echo "export PYTHONPATH=${WORKSPACE}" >>~/.bashrc
33+
34+
# make conda activate command available from /bin/bash (login and interactive)
35+
if [[ ! -f "/etc/profile.d/conda.sh" ]]; then
36+
ln -s ${CONDA_DIR}/etc/profile.d/conda.sh /etc/profile.d/conda.sh
37+
fi
38+
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh" >>~/.bashrc
39+
echo "conda activate pandas-dev" >>~/.bashrc
40+
41+
# Enable prompt color in the skeleton .bashrc
42+
# hadolint ignore=SC2016
43+
sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
44+
45+
# .gitpod.yml is configured to install pandas from /workspace/pandas
46+
echo "export PYTHONPATH=/workspace/pandas" >>~/.bashrc
47+
48+
# Set up ccache for compilers for this Dockerfile
49+
# REF: https://github.com/conda-forge/compilers-feedstock/issues/31
50+
echo "conda activate pandas-dev" >>~/.startuprc
51+
echo "export CC=\"ccache \$CC\"" >>~/.startuprc
52+
echo "export CXX=\"ccache \$CXX\"" >>~/.startuprc
53+
echo "source ~/.startuprc" >>~/.profile
54+
echo "source ~/.startuprc" >>~/.bashrc

0 commit comments

Comments
 (0)