Skip to content

Commit ca20736

Browse files
committed
add gitpod files
1 parent d47e052 commit ca20736

File tree

5 files changed

+276
-0
lines changed

5 files changed

+276
-0
lines changed

.gitpod.yml

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

gitpod/Dockerfile

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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="4.11.0-0"
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+
# -----------------------------------------------------------------------------
43+
# ---- Creating as root - note: make sure to change to gitpod in the end ----
44+
USER root
45+
46+
# Avoid warnings by switching to noninteractive
47+
ENV DEBIAN_FRONTEND=noninteractive
48+
49+
# Configure apt and install packages
50+
RUN apt-get update \
51+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
52+
#
53+
# Install tzdata and configure timezone (fix for tests which try to read from "/etc/localtime")
54+
&& apt-get -y install tzdata \
55+
&& ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \
56+
&& dpkg-reconfigure -f noninteractive tzdata \
57+
#
58+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
59+
&& apt-get -y install git iproute2 procps iproute2 lsb-release \
60+
#
61+
# cleanup
62+
&& apt-get autoremove -y \
63+
&& apt-get clean -y \
64+
&& rm -rf /var/lib/apt/lists/*
65+
66+
# Switch back to dialog for any ad-hoc use of apt-get
67+
ENV DEBIAN_FRONTEND=dialog
68+
69+
# Allows this Dockerfile to activate conda environments
70+
SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
71+
72+
# -----------------------------------------------------------------------------
73+
# ---- Installing mamba ----
74+
RUN wget -q -O mambaforge3.sh \
75+
"https://github.com/conda-forge/miniforge/releases/download/$MAMBAFORGE_VERSION/Mambaforge-$MAMBAFORGE_VERSION-Linux-x86_64.sh" && \
76+
bash mambaforge3.sh -p ${CONDA_DIR} -b && \
77+
rm mambaforge3.sh
78+
79+
# -----------------------------------------------------------------------------
80+
# ---- Copy needed files ----
81+
# basic workspace configurations
82+
COPY ./gitpod/workspace_config /usr/local/bin/workspace_config
83+
84+
RUN chmod a+rx /usr/local/bin/workspace_config && \
85+
workspace_config
86+
87+
# Copy conda environment file into the container - this needs to exists inside
88+
# the container to create a conda environment from it
89+
COPY environment.yml /tmp/environment.yml
90+
91+
# -----------------------------------------------------------------------------
92+
# ---- Create conda environment ----
93+
# Install pandas dependencies
94+
RUN mamba env create -f /tmp/environment.yml
95+
RUN conda activate ${CONDA_ENV} && \
96+
mamba install ccache -y && \
97+
# needed for docs rendering later on
98+
python -m pip install --no-cache-dir sphinx-autobuild && \
99+
conda clean --all -f -y && \
100+
rm -rf /tmp/*
101+
102+
# -----------------------------------------------------------------------------
103+
# Always make sure we are not root
104+
USER gitpod

gitpod/gitpod.Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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="pandas/pandas-dev:latest"
5+
FROM gitpod/workspace-base:latest as clone
6+
7+
COPY --chown=gitpod . /tmp/pandas_repo
8+
9+
# the clone should be deep enough for versioneer to work
10+
RUN git clone --shallow-since=2022-01-01 file:////tmp/pandas_repo /tmp/pandas
11+
12+
# -----------------------------------------------------------------------------
13+
# Using the pandas-dev Docker image as a base
14+
# This way, we ensure we have all the needed compilers and dependencies
15+
# while reducing the build time
16+
FROM ${BASE_CONTAINER} as build
17+
18+
# -----------------------------------------------------------------------------
19+
USER root
20+
21+
# -----------------------------------------------------------------------------
22+
# ---- ENV variables ----
23+
# ---- Directories needed ----
24+
ENV WORKSPACE=/workspace/pandas/ \
25+
CONDA_ENV=pandas-dev
26+
27+
# Allows this Dockerfile to activate conda environments
28+
SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
29+
30+
# Copy over the shallow clone
31+
COPY --from=clone --chown=gitpod /tmp/pandas ${WORKSPACE}
32+
33+
# Everything happens in the /workspace/pandas directory
34+
WORKDIR ${WORKSPACE}
35+
36+
# Build pandas to populate the cache used by ccache
37+
RUN git config --global --add safe.directory /workspace/pandas
38+
# chained RUN failed to activate. trying separate run commands
39+
RUN git submodule update --init --depth=1 -- pandas/core/src/umath/svml
40+
RUN conda activate ${CONDA_ENV} && \
41+
python setup.py build_ext --inplace && \
42+
ccache -s
43+
44+
# Gitpod will load the repository into /workspace/pandas. We remove the
45+
# directory from the image to prevent conflicts
46+
RUN rm -rf ${WORKSPACE}
47+
48+
# -----------------------------------------------------------------------------
49+
# Always return to non privileged user
50+
USER gitpod

gitpod/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
"esbonio.sphinx.buildDir": "${workspaceRoot}/doc/build/html",
7+
"esbonio.sphinx.confDir": ""
8+
}

gitpod/workspace_config

Lines changed: 54 additions & 0 deletions
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)