Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Python 2.7 and 3.6 on Centos6 base image through Pyenv #7064

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
37da616
install python3 on the centos6 image
cosmicexplorer Jan 12, 2019
a0c3482
move python 3 bootstrapping to use pyenv in travis_ci/Dockerfile
cosmicexplorer Jan 12, 2019
7dee60a
add a very annoying note
cosmicexplorer Jan 12, 2019
1ee451d
move py3 install to centos6 base image
cosmicexplorer Jan 13, 2019
a55d92f
install python 2 with pyenv as well
cosmicexplorer Jan 14, 2019
87157ec
maybe update to make things work without pyenv-installer
cosmicexplorer Mar 10, 2019
990bb6b
fix docker permissions
cosmicexplorer Mar 10, 2019
4b1cf69
remove centos6 base image changes for now
cosmicexplorer Mar 10, 2019
ff47eb2
enable building python as a shared library in the docker image
cosmicexplorer Mar 10, 2019
c205036
try adding a clean to the bootstrap args for the py27 pex shard
cosmicexplorer Mar 11, 2019
5fb981c
remove travis_ci_py36
cosmicexplorer Mar 12, 2019
a18380e
add note on -x in py2 bootstrap shard
cosmicexplorer Mar 12, 2019
e9a0b7d
add openssl and other required libs to the travis_ci dockerfile
cosmicexplorer Mar 12, 2019
7ec054a
move everything to centos6 dockerfile too
cosmicexplorer Mar 12, 2019
5fad238
remove openssl and abbreviate PYENV_BIN
cosmicexplorer Mar 16, 2019
921d80c
remove reference to deleted travis ci image for py3.6
cosmicexplorer Mar 18, 2019
84da10c
some review comments
cosmicexplorer Apr 4, 2019
a06bfbe
more review comments
cosmicexplorer Apr 4, 2019
9e228c2
make the travis_ci dockerfile work with or without the centos6 change
cosmicexplorer Apr 4, 2019
9989083
respond to review comments
cosmicexplorer Apr 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ py27_linux_build_engine: &py27_linux_build_engine
name: "Build Linux native engine and pants.pex (Py2.7 PEX)"
env:
- docker_image_name=travis_ci
# We also build fs_util.
- docker_run_command="./build-support/bin/ci.sh -2b
&& ./build-support/bin/release.sh -f"
# TODO: While this image shouldn't have any cache to fetch anything from, it fails to find
# libpython2.7.so.1 during the cargo build, despite the image being built with --enable-shared,
# unless the -x argument is added. This isn't expected to affect build time too much.
- docker_run_command="./build-support/bin/ci.sh -2bx && ./build-support/bin/release.sh -f"
- PREPARE_DEPLOY=1
- CACHE_NAME=linuxpexbuild.py27
- BOOTSTRAPPED_PEX_KEY_SUFFIX=py27.linux
Expand All @@ -356,7 +357,7 @@ py36_linux_build_engine: &py36_linux_build_engine
<<: *base_linux_build_engine
name: "Build Linux native engine and pants.pex (Py3.6 PEX)"
env:
- docker_image_name=travis_ci_py36
- docker_image_name=travis_ci
- docker_run_command="./build-support/bin/ci.sh -b"
- CACHE_NAME=linuxpexbuild.py36
- BOOTSTRAPPED_PEX_KEY_SUFFIX=py36.linux
Expand Down Expand Up @@ -563,7 +564,7 @@ py36_linux_build_wheels: &py36_linux_build_wheels
env:
- *py36_linux_test_config_env
- *base_build_wheels_env
- docker_image_name=travis_ci_py36
- docker_image_name=travis_ci
cosmicexplorer marked this conversation as resolved.
Show resolved Hide resolved
- docker_run_command="./build-support/bin/check_pants_pex_abi.py cp36m
&& RUN_PANTS_FROM_PEX=1 ./build-support/bin/release.sh -3n"
- CACHE_NAME=linuxwheelsbuild.abi3
Expand Down
42 changes: 31 additions & 11 deletions build-support/docker/centos6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,38 @@
# Use centos6 for compatibility with glibc 2.12.
FROM centos:6

# Install python 2.7.13, (more) modern gcc, and a JDK.
# Install a (more) modern gcc, a JDK, and dependencies for installing Python through Pyenv.
# Also install sqlite-devel because Python 3 errors on startup if not -- see
# https://stackoverflow.com/a/39907500/2518889.
cosmicexplorer marked this conversation as resolved.
Show resolved Hide resolved
RUN yum -y update
# TODO: figure out why this needs to be installed first for /usr/bin/scl to work!
RUN yum install -y centos-release-scl
RUN yum install -y \
devtoolset-7-gcc \
devtoolset-7-gcc-c++ \
git \
java-1.8.0-openjdk-devel \
python27 \
libffi \
libffi-devel \
openssl-devel
bzip2-devel \
devtoolset-7-gcc{,-c++} \
git \
java-1.8.0-openjdk-devel \
libffi-devel \
openssl-devel \
readline-devel \
sqlite-devel \
zlib-devel

Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
# By default, execute in an environment with python27 enabled.
ENTRYPOINT ["/usr/bin/scl", "enable", "python27", "devtoolset-7", "--"]
ARG PYTHON_27_VERSION=2.7.13
ARG PYTHON_36_VERSION=3.6.8
# NB: PYENV_ROOT must be set for `pyenv install` to be available. This failure mode is not mentioned
# in https://github.com/pyenv/pyenv#basic-github-checkout.
ENV PYENV_ROOT /pyenv-docker-build
cosmicexplorer marked this conversation as resolved.
Show resolved Hide resolved
ENV PYENV_BIN "${PYENV_ROOT}/bin/pyenv"
RUN git clone https://github.com/pyenv/pyenv ${PYENV_ROOT}

# Install Python 2.7 and 3.6.
# Build the Python shared library, as we use it to build the engine.
ENV PYTHON_CONFIGURE_OPTS="--enable-shared"
RUN /usr/bin/scl enable devtoolset-7 -- ${PYENV_BIN} install ${PYTHON_27_VERSION}
RUN /usr/bin/scl enable devtoolset-7 -- ${PYENV_BIN} install ${PYTHON_36_VERSION}
RUN ${PYENV_BIN} global ${PYTHON_27_VERSION} ${PYTHON_36_VERSION}
ENV PATH "${PYENV_ROOT}/shims:${PATH}"
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved

# Expose the installed gcc to the invoking shell.
ENTRYPOINT ["/usr/bin/scl", "enable", "devtoolset-7", "--"]
61 changes: 55 additions & 6 deletions build-support/docker/travis_ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,53 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

# Use our custom Centos6 image for binary compatibility with old linux distros.
FROM pantsbuild/centos6:latest
ARG BASE_IMAGE=pantsbuild/centos6:latest
FROM ${BASE_IMAGE}

# Setup mount points for the travis ci user & workdir.
VOLUME /travis/home
VOLUME /travis/workdir
# TODO(7064) These changes belong in centos6/Dockerfile, because we always want that image to
# have Py3 available and also avoid the cost of rebuilding Python 3 every time in CI. However,
# this requires publishing an updated image to Docker hub, so we copy the code here until then.

### BEGIN CENTOS6 DOCKERFILE CHANGES
RUN yum -y update
# TODO: figure out why this needs to be installed first for /usr/bin/scl to work!
RUN yum install -y centos-release-scl
RUN yum install -y \
bzip2-devel \
devtoolset-7-gcc{,-c++} \
git \
java-1.8.0-openjdk-devel \
libffi-devel \
openssl-devel \
readline-devel \
sqlite-devel \
zlib-devel

ARG PYTHON_27_VERSION=2.7.13
ARG PYTHON_36_VERSION=3.6.8
# NB: PYENV_ROOT must be set for `pyenv install` to be available. This failure mode is not mentioned
# in https://github.com/pyenv/pyenv#basic-github-checkout.
ENV PYENV_ROOT "${PYENV_ROOT:-/pyenv-docker-build}"
ENV PYENV_BIN "${PYENV_ROOT}/bin/pyenv"
ENV PYTHON_CONFIGURE_OPTS="--enable-shared"
RUN if [[ ! -d "${PYENV_ROOT}" ]]; then \
git clone https://github.com/pyenv/pyenv ${PYENV_ROOT} \
&& /usr/bin/scl enable devtoolset-7 -- ${PYENV_BIN} install ${PYTHON_27_VERSION} \
&& /usr/bin/scl enable devtoolset-7 -- ${PYENV_BIN} install ${PYTHON_36_VERSION} \
&& ${PYENV_BIN} global ${PYTHON_27_VERSION} ${PYTHON_36_VERSION}; \
fi
ENV PATH "${PYENV_ROOT}/shims:${PATH}"

# Expose the installed gcc to the invoking shell.
ENTRYPOINT ["/usr/bin/scl", "enable", "devtoolset-7", "--"]

### END CENTOS6 DOCKERFILE CHANGES

ARG TRAVIS_HOME_DIR_PATH=/travis/home
ARG TRAVIS_WORK_DIR_PATH=/travis/workdir

RUN mkdir -p ${TRAVIS_HOME_DIR_PATH}
RUN mkdir -p ${TRAVIS_WORK_DIR_PATH}

# Setup a non-root user to execute the build under (avoids problems with npm install).
ARG TRAVIS_USER=travis_ci
Expand All @@ -15,7 +57,11 @@ ARG TRAVIS_GROUP=root
ARG TRAVIS_GID=0

RUN groupadd --gid ${TRAVIS_GID} ${TRAVIS_GROUP} || true
RUN useradd -d /travis/home -g ${TRAVIS_GROUP} --uid ${TRAVIS_UID} ${TRAVIS_USER}
RUN useradd -d ${TRAVIS_HOME_DIR_PATH} -g ${TRAVIS_GROUP} --uid ${TRAVIS_UID} ${TRAVIS_USER}

RUN chown -R ${TRAVIS_USER} ${TRAVIS_HOME_DIR_PATH}
RUN chown -R ${TRAVIS_USER} ${TRAVIS_WORK_DIR_PATH}

USER ${TRAVIS_USER}:${TRAVIS_GROUP}

# Our newly created user is unlikely to have a sane environment: set a locale at least.
Expand All @@ -26,4 +72,7 @@ ENV LC_ALL="en_US.UTF-8"
# clean-all without this env var.
ENV ONLY_USING_SINGLE_PYTHON_VERSION 'true'

WORKDIR /travis/workdir
# Expose the installed gcc to the invoking shell.
ENTRYPOINT ["/usr/bin/scl", "enable", "devtoolset-7", "--"]

WORKDIR ${TRAVIS_WORK_DIR_PATH}
6 changes: 4 additions & 2 deletions build-support/docker/travis_ci_py27_ucs2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ RUN yum install sqlite-devel -y
ENV PYENV_ROOT "${PYENV_ROOT:-/pyenv-docker-build}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cosmicexplorer can you please remove lines 19 and 20: RUN yum install sqlite-devel -y. We don't need them anymore.

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_BIN} install ${PYTHON_27_VERSION_UCS2}'
RUN /usr/bin/scl enable devtoolset-7 -- bash -c '${PYENV_BIN} global ${PYTHON_27_VERSION_UCS2}'
RUN /usr/bin/scl enable devtoolset-7 -- ${PYENV_BIN} install ${PYTHON_27_VERSION_UCS2}
RUN /usr/bin/scl enable devtoolset-7 -- ${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
51 changes: 0 additions & 51 deletions build-support/docker/travis_ci_py36/Dockerfile

This file was deleted.

11 changes: 6 additions & 5 deletions build-support/travis/travis.yml.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,10 @@ py27_linux_build_engine: &py27_linux_build_engine
name: "Build Linux native engine and pants.pex (Py2.7 PEX)"
env:
- docker_image_name=travis_ci
# We also build fs_util.
- docker_run_command="./build-support/bin/ci.sh -2b
&& ./build-support/bin/release.sh -f"
# TODO: While this image shouldn't have any cache to fetch anything from, it fails to find
# libpython2.7.so.1 during the cargo build, despite the image being built with --enable-shared,
# unless the -x argument is added. This isn't expected to affect build time too much.
- docker_run_command="./build-support/bin/ci.sh -2bx && ./build-support/bin/release.sh -f"
- PREPARE_DEPLOY=1
- CACHE_NAME=linuxpexbuild.py27
- BOOTSTRAPPED_PEX_KEY_SUFFIX=py27.linux
Expand All @@ -314,7 +315,7 @@ py36_linux_build_engine: &py36_linux_build_engine
<<: *base_linux_build_engine
name: "Build Linux native engine and pants.pex (Py3.6 PEX)"
env:
- docker_image_name=travis_ci_py36
- docker_image_name=travis_ci
- docker_run_command="./build-support/bin/ci.sh -b"
- CACHE_NAME=linuxpexbuild.py36
- BOOTSTRAPPED_PEX_KEY_SUFFIX=py36.linux
Expand Down Expand Up @@ -510,7 +511,7 @@ py36_linux_build_wheels: &py36_linux_build_wheels
env:
- *py36_linux_test_config_env
- *base_build_wheels_env
- docker_image_name=travis_ci_py36
- docker_image_name=travis_ci
- docker_run_command="./build-support/bin/check_pants_pex_abi.py cp36m
&& RUN_PANTS_FROM_PEX=1 ./build-support/bin/release.sh -3n"
- CACHE_NAME=linuxwheelsbuild.abi3
Expand Down