summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas J. Fan <thomasjpfan@gmail.com>2021-04-11 10:24:49 -0400
committerGitHub <noreply@github.com>2021-04-11 16:24:49 +0200
commit4a53ea1ce65536748e68b7ab76779b9bb72e4619 (patch)
tree4838a05af4b5da70c177590020b3adb80c4fca14
parent36eb76c9ded81c6626a86aa06d137dd800350751 (diff)
downloadnumpy-4a53ea1ce65536748e68b7ab76779b9bb72e4619.tar.gz
DEV: add Gitpod to numpy (#18733)
-rw-r--r--.gitpod.yml10
-rw-r--r--environment.yml1
-rw-r--r--tools/gitpod/Dockerfile74
3 files changed, 85 insertions, 0 deletions
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 000000000..c1755607b
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,10 @@
+image: thomasjpfan/numpy-gitpod:latest
+tasks:
+ # The base image complied numpy with ccache enabled. This second build
+ # should be faster since it is using the cache.
+ - init: python setup.py build_ext -i
+
+github:
+ prebuilds:
+ master: true
+ branches: true
diff --git a/environment.yml b/environment.yml
index ecfebee3e..ea38882a2 100644
--- a/environment.yml
+++ b/environment.yml
@@ -9,6 +9,7 @@ dependencies:
- cython
- compilers
- openblas
+ - nomkl
# For testing
- pytest
- pytest-cov
diff --git a/tools/gitpod/Dockerfile b/tools/gitpod/Dockerfile
new file mode 100644
index 000000000..b9c0d4449
--- /dev/null
+++ b/tools/gitpod/Dockerfile
@@ -0,0 +1,74 @@
+# Builds a development environment for gitpod by building numpy with
+# ccache enabled. When gitpod is prebuilding or starting up it clones
+# a branch into `/workspace/numpy`. The gitpod clone will build numpy
+# faster because it is using compliers with ccache enabled.
+FROM gitpod/workspace-base as clone
+
+COPY --chown=gitpod . /tmp/numpy_repo
+
+# We use a multistage build to create a shallow clone of the repo to avoid
+# having the complete git history in the build stage and reducing the image
+# size. During the build stage, the shallow clone is used to install the
+# dependencies and build numpy to populate the cache used by ccache. Building
+# numpy with setup.py uses versioneer.py which requires a git history.
+RUN git clone --depth 1 file:////tmp/numpy_repo /tmp/numpy
+
+FROM gitpod/workspace-base as build
+
+# gitpod/workspace-base needs at least one file here
+RUN touch /home/gitpod/.bashrc.d/empty
+
+ARG MAMBAFORGE_VERSION="4.10.0-0"
+ARG CONDA_ENV=numpy-dev
+
+ENV CONDA_DIR=/home/gitpod/mambaforge3
+ENV PATH=$CONDA_DIR/bin:$PATH
+
+USER root
+RUN install-packages texlive-latex-extra dvisvgm
+USER gitpod
+
+# Allows this Dockerfile to activate conda environments
+SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
+
+# Install mambaforge3
+RUN wget -q -O mambaforge3.sh \
+ https://github.com/conda-forge/miniforge/releases/download/$MAMBAFORGE_VERSION/Mambaforge-$MAMBAFORGE_VERSION-Linux-x86_64.sh && \
+ bash mambaforge3.sh -p $CONDA_DIR -b && \
+ rm mambaforge3.sh
+
+# makes conda activate command for this Dockerfile
+RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.profile
+# enables conda for interactive sessions
+RUN conda init bash
+
+# Install numpy dev dependencies
+COPY --from=clone --chown=gitpod /tmp/numpy /workspace/numpy
+RUN mamba env create -f /workspace/numpy/environment.yml -n $CONDA_ENV && \
+ conda activate $CONDA_ENV && \
+ mamba install ccache -y && \
+ conda clean --all -f -y
+
+# Set up ccache for compilers for this Dockerfile and interactino sessions
+# Using `conda env config vars set` does not work with Docker
+# REF: https://github.com/conda-forge/compilers-feedstock/issues/31
+RUN echo "conda activate $CONDA_ENV" >> ~/.startuprc && \
+ echo "export CC=\"ccache \$CC\"" >> ~/.startuprc && \
+ echo "export CXX=\"ccache \$CXX\"" >> ~/.startuprc && \
+ echo "export F77=\"ccache \$F77\"" >> ~/.startuprc && \
+ echo "export F90=\"ccache \$F90\"" >> ~/.startuprc && \
+ echo "export GFORTRAN=\"ccache \$GFORTRAN\"" >> ~/.startuprc && \
+ echo "export FC=\"ccache \$FC\"" >> ~/.startuprc && \
+ echo "source ~/.startuprc" >> ~/.profile && \
+ echo "source ~/.startuprc" >> ~/.bashrc
+
+# Build numpy to populate the cache used by ccache
+RUN python /workspace/numpy/setup.py build_ext -i && \
+ ccache -s
+
+# .gitpod.yml is configured to install numpy from /workspace/numpy
+RUN echo "export PYTHONPATH=/workspace/numpy" >> ~/.bashrc
+
+# gitpod will load the repository into /workspace/numpy. We remove the
+# directoy from the image to prevent conflicts
+RUN sudo rm -rf /workspace/numpy