1+
2+ # Kaggle-specific .bashrc script to be appended to /etc/bash.bashrc to apply it
3+ # when any user session starts.
4+ # This script sets up pip to enable a user to install and use python modules via
5+ # pip intall. $KAGGLE_WORKING_DIR should be available for it to work.
6+
7+ if [[ ! -z "${KAGGLE_WORKING_DIR}" ]]; then
8+ PIP_INSTALL_PREFIX_DIR="${KAGGLE_WORKING_DIR}/pip"
9+ PIP_CONFIG_FILE_PATH="${KAGGLE_WORKING_DIR}/config/pip/pip.conf"
10+
11+ # Create a directory for pip to install modules.
12+ mkdir -p ${PIP_INSTALL_PREFIX_DIR}
13+
14+ # Create pip config file to use the prefix directory created above for
15+ # installation. Also, ignore-installed is set to true to prevent pip
16+ # from trying to remove existing modules from the read-only filesystem.
17+ mkdir -p `dirname ${PIP_CONFIG_FILE_PATH}`
18+ echo "[install]\nprefix=${PIP_INSTALL_PREFIX_DIR}\nignore-installed=true" > ${PIP_CONFIG_FILE_PATH}
19+ # Instruct pip to use this config file.
20+ export PIP_CONFIG_FILE=${PIP_CONFIG_FILE_PATH}
21+
22+ # Set up PYTHONPATH correctly to include the user-installed library.
23+ # Note that the pip prefix directory overrides the system default to enable
24+ # a user to use his/her installed one.
25+ # TODO(dsjang): Currently "lib/python3.6/site-packages" is hard-coded
26+ # throughout Dockerfile. Parameterize it to avoid a version mismatch.
27+ export PYTHONPATH=${PIP_INSTALL_PREFIX_DIR}/lib/python3.6/site-packages:${PYTHONPATH}
28+
29+ # Include pip-installed binaries in PATH.
30+ export PATH=${PATH}:${PIP_INSTALL_PREFIX_DIR}/bin
31+ fi
0 commit comments