| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -535,6 +535,12 @@ ADD patches/sitecustomize.py /root/.local/lib/python3.6/site-packages/sitecustom | |||
| 535 | 535 | # Set backend for matplotlib | |
| 536 | 536 | ENV MPLBACKEND "agg" | |
| 537 | 537 | ||
| 538 | + # Set up pip to enable pip install. | ||
| 539 | + ADD patches/kaggle_bashrc /root | ||
| 540 | + # Patch the system-wide bashrc file for non-root users. | ||
| 541 | + RUN cat /root/kaggle_bashrc >> /etc/bash.bashrc | ||
| 542 | + RUN rm /root/kaggle_bashrc | ||
| 543 | + | ||
| 538 | 544 | # Finally, apply any locally defined patches. | |
| 539 | 545 | RUN /bin/bash -c \ | |
| 540 | 546 | "cd / && for p in $(ls /tmp/patches/*.patch); do echo '= Applying patch '\${p}; patch -p2 < \${p}; done" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 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 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments