Skip to content

Commit

Permalink
Prepare Linux UCS2 shard for upgrade to Centos6 base image in #7064 (#…
Browse files Browse the repository at this point in the history
…7418)

### Problem
We will in #7064 start using Pyenv to install Python 2.7 in the base Centos6 image. 

This will conflict with our Linux UCS2 shard, which currently uses Pyenv to install Python 2.7 with UCS2 instead of the default UCS4.

### Solution
Tweak the Dockerfile to avoid any ambiguity with Centos6 image:

* Rename the Python version env var to not conflict by marking it as `UCS2`.
* Check if `PYENV_ROOT` is already defined.
* Check if `PYENV_ROOT` already exists before git cloning to avoid a git failure.

The key line is `${PYENV_BIN} global ${PYTHON_27_VERSION_UCS2}`, which will override whatever `${PYENV_ROOT}/shims/python2.7` used to point to.
  • Loading branch information
Eric-Arellano authored and stuhood committed Apr 8, 2019
1 parent 0e80e33 commit 937b55b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions build-support/docker/travis_ci_py27_ucs2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ FROM pantsbuild/centos6:latest
# interpreter to use when `ci.sh` and `release.sh` set the interpreter constraints for
# Pants, and thus for the built ./pants.pex. We set $PY to the exact Python 2.7 version we want
# to ensure the PEX is bootstrapped with UCS 2.
ARG PYTHON_2_VERSION=2.7.15
ARG PYTHON_27_VERSION_UCS2=2.7.15
# TODO(7064): remove this yum install line once we update the base Centos6 image to include this dependency.
RUN yum install sqlite-devel -y
ENV PYENV_ROOT /pyenv-docker-build
RUN mkdir ${PYENV_ROOT}
RUN git clone https://github.com/pyenv/pyenv ${PYENV_ROOT}
ENV PYENV_ROOT "${PYENV_ROOT:-/pyenv-docker-build}"
ENV PYENV_BIN "${PYENV_ROOT}/bin/pyenv"
RUN if [[ ! -d "${PYENV_ROOT}" ]]; then git clone https://github.com/pyenv/pyenv ${PYENV_ROOT}; fi
ENV PYTHON_CONFIGURE_OPTS --enable-unicode=ucs2
RUN /usr/bin/scl enable devtoolset-7 -- bash -c '\
${PYENV_ROOT}/bin/pyenv install ${PYTHON_2_VERSION} \
&& ${PYENV_ROOT}/bin/pyenv global ${PYTHON_2_VERSION}'
RUN /usr/bin/scl enable devtoolset-7 -- bash -c '${PYENV_BIN} install ${PYTHON_27_VERSION_UCS2}'
RUN /usr/bin/scl enable devtoolset-7 -- bash -c '${PYENV_BIN} global ${PYTHON_27_VERSION_UCS2}'
ENV PATH "${PYENV_ROOT}/shims:${PATH}"
ENV PY "${PYENV_ROOT}/shims/python2.7"
ENV PEX_PYTHON_PATH "${PYENV_ROOT}/shims/python2.7"
Expand Down

0 comments on commit 937b55b

Please sign in to comment.