Commit e4c54c90 authored by Min RK's avatar Min RK

finish removing files from $HOME

- mplimporthook should be obsolete with matplotlib 2.0
- curlrc seems to be obsolete now (updates to base image?)
- set WORKDIR to $HOME instead of $HOME/work (leave work there for compatibility)
parent 11be019e
......@@ -52,9 +52,8 @@ RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
USER $NB_USER
# Setup jovyan home directory
RUN mkdir /home/$NB_USER/work && \
echo "cacert=/etc/ssl/certs/ca-certificates.crt" > /home/$NB_USER/.curlrc
# Setup work directory for backward-compatibility
RUN mkdir /home/$NB_USER/work
# Install conda as jovyan
RUN cd /tmp && \
......@@ -77,7 +76,7 @@ RUN conda install --quiet --yes \
USER root
EXPOSE 8888
WORKDIR /home/$NB_USER/work
WORKDIR $HOME
# Configure container startup
ENTRYPOINT ["tini", "--"]
......
......@@ -86,10 +86,6 @@ RUN ln -s $CONDA_DIR/envs/python2/bin/pip $CONDA_DIR/bin/pip2 && \
ENV XDG_CACHE_HOME /home/$NB_USER/.cache/
RUN MPLBACKEND=Agg $CONDA_DIR/envs/python2/bin/python -c "import matplotlib.pyplot"
# Configure ipython kernel to use matplotlib inline backend by default
RUN mkdir -p $HOME/.ipython/profile_default/startup
COPY mplimporthook.py $HOME/.ipython/profile_default/startup/
USER root
# Install Python 2 kernel spec globally to avoid permission problems when NB_UID
......
"""Startup script for IPython kernel.
Installs an import hook to configure the matplotlib backend on the fly.
Originally from @minrk at
https://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py
Repurposed for docker-stacks to address repeat bugs like
https://github.com/jupyter/docker-stacks/issues/235.
"""
import sys
from IPython import get_ipython
class MatplotlibFinder(object):
"""Import hook that notices when matplotlib.pyplot or pylab is imported
and tries to configure the matplotlib backend appropriately for the
environment.
"""
_called = False
def find_module(self, fullname, path=None):
if self._called:
# already handled
return
if fullname not in ('pylab', 'matplotlib.pyplot'):
# not matplotlib
return
# don't call me again
self._called = True
try:
# remove myself from the import hooks
sys.meta_path = [loader for loader in sys.meta_path if loader is not self]
except ValueError:
pass
ip = get_ipython()
if ip is None:
# not in an interactive environment
return
if ip.pylab_gui_select:
# backend already selected
return
if hasattr(ip, 'kernel'):
# default to inline in kernel environments
ip.enable_matplotlib('inline')
else:
print('enabling matplotlib')
ip.enable_matplotlib()
# install the finder immediately
sys.meta_path.insert(0, MatplotlibFinder())
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment