Skip to content

Commit 12c12db

Browse files
squash merge pants3-in-ci
merge sha 2dfb39d and push to travis to ensure that PR works
1 parent 1be1a25 commit 12c12db

File tree

9 files changed

+1117
-519
lines changed

9 files changed

+1117
-519
lines changed

.travis.yml

Lines changed: 612 additions & 305 deletions
Large diffs are not rendered by default.

build-support/bin/ci.sh

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# We use some subshell pipelines to collect target lists, make sure target collection failing
44
# fails the build.
5-
set -o pipefail
5+
set -ox pipefail
66

77
REPO_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}") && cd "$(git rev-parse --show-toplevel)" && pwd)
88
cd ${REPO_ROOT}
@@ -13,10 +13,9 @@ function usage() {
1313
cat <<EOF
1414
Runs commons tests for local or hosted CI.
1515
16-
Usage: $0 (-h|-3fxbkmrjlpuneycitzs)
16+
Usage: $0 (-h|-2fxbkmrjlpuneycitzs)
1717
-h print out this help message
18-
-3 After pants is bootstrapped, set --python-setup-interpreter-constraints such that any
19-
python tests run with Python 3.
18+
-2 Run using Python 2 (defaults to using Python 3).
2019
-f run python code formatting checks
2120
-x run bootstrap clean-all (assume bootstrapping from a
2221
fresh clone)
@@ -58,12 +57,12 @@ EOF
5857
python_unit_shard="0/1"
5958
python_contrib_shard="0/1"
6059
python_intg_shard="0/1"
61-
python_three="false"
60+
python_two="false"
6261

63-
while getopts "h3fxbmrjlpeasu:ny:ci:tz" opt; do
62+
while getopts "h2fxbmrjlpeasu:ny:ci:tz" opt; do
6463
case ${opt} in
6564
h) usage ;;
66-
3) python_three="true" ;;
65+
2) python_two="true" ;;
6766
f) run_pre_commit_checks="true" ;;
6867
x) run_bootstrap_clean="true" ;;
6968
b) run_bootstrap="false" ;;
@@ -104,13 +103,26 @@ esac
104103
# We're running against a Pants clone.
105104
export PANTS_DEV=1
106105

106+
# Determine interpreter for both under-the-hood and for subprocesses.
107+
# Order matters here. We must constrain subprocesses before running the bootstrap stage,
108+
# or we will encounter the _Py_Dealloc error when running `./pants.pex -V` with Python 3 under-the-hood.
109+
if [[ "${python_two:-false}" == "false" ]]; then
110+
py_version_number="3"
111+
pants_script="./pants3"
112+
export PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS='["CPython>=3.6,<4"]'
113+
else
114+
py_version_number="2"
115+
pants_script="./pants"
116+
fi
117+
banner "Using Python ${py_version_number} to execute subprocesses."
118+
107119
if [[ "${run_bootstrap:-true}" == "true" ]]; then
108-
start_travis_section "Bootstrap" "Bootstrapping pants"
120+
start_travis_section "Bootstrap" "Bootstrapping pants with Python ${py_version_number} under-the-hood."
109121
(
110122
if [[ "${run_bootstrap_clean:-false}" == "true" ]]; then
111123
./build-support/python/clean.sh || die "Failed to clean before bootstrapping pants."
112124
fi
113-
./pants binary \
125+
${pants_script} binary \
114126
src/python/pants/bin:pants_local_binary && \
115127
mv dist/pants_local_binary.pex pants.pex && \
116128
./pants.pex -V
@@ -124,21 +136,16 @@ fi
124136
# integration tests that shell out to `./pants`, so we set this env var for those cases.
125137
export RUN_PANTS_FROM_PEX=1
126138

139+
# TODO: Clear interpreters, otherwise the above subprocess interpreter constraint does not end up
140+
# applying due to a cache bug between the `./pants binary` and further runs.
141+
./pants.pex clean-all
142+
127143
if [[ "${run_pre_commit_checks:-false}" == "true" ]]; then
128144
start_travis_section "PreCommit" "Running pre-commit checks"
129145
FULL_CHECK=1 ./build-support/bin/pre-commit.sh || exit 1
130146
end_travis_section
131147
fi
132148

133-
# NB: Ordering matters here. We (currently) always bootstrap a Python 2 pex.
134-
if [[ "${python_three:-false}" == "true" ]]; then
135-
banner "Setting interpreter constraints for 3!"
136-
export PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS='["CPython>=3.6,<4"]'
137-
# TODO: Clear interpreters, otherwise this constraint does not end up applying due to a cache
138-
# bug between the `./pants binary` and further runs.
139-
./pants.pex clean-all
140-
fi
141-
142149
if [[ "${run_sanity_checks:-false}" == "true" ]]; then
143150
start_travis_section "SanityCheck" "Sanity checking bootstrapped pants and repo BUILD files"
144151
sanity_tests=(

build-support/bin/travis-ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# TravisCI-specific environment fixups can live in this script which forwards to the generic ci
66
# script post fixups.
77

8-
set -euo pipefail
8+
set -euox pipefail
99

1010
cd "$(git rev-parse --show-toplevel)"
1111

build-support/docker/travis_ci/Dockerfile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ RUN mkdir -p /travis/home
2828
RUN echo >> /travis/home/.bashrc 'eval "$(pyenv init -)"'
2929
RUN echo >> /travis/home/.bashrc 'eval "$(pyenv virtualenv-init -)"'
3030

31+
# -----------------------------------------------------------------------
32+
# This section belongs in centos6, but is here temporarily because
33+
# centos6's build must first be published to Docker.
34+
35+
RUN mkdir -p /python-3-docker-build/python-3.6.8-{source,install}
36+
RUN curl -L -v https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz \
37+
| tar -zxvC /python-3-docker-build/python-3.6.8-source
38+
RUN ls -lAvF /python-3-docker-build/python-3.6.8-source
39+
RUN /usr/bin/scl enable devtoolset-7 -- \
40+
bash -c 'pushd /python-3-docker-build/python-3.6.8-source/Python-3.6.8 \
41+
&& ./configure --prefix=/python-3-docker-build/python-3.6.8-install \
42+
--enable-optimizations \
43+
&& make install'
44+
ENV PATH "${PATH}:/python-3-docker-build/python-3.6.8-install/bin"
45+
RUN ls -lAvF /python-3-docker-build/python-3.6.8-install/bin
46+
47+
# -----------------------------------------------------------------------
48+
3149
# Setup mount points for the travis ci user & workdir.
3250
VOLUME /travis/home
3351
VOLUME /travis/workdir
@@ -42,9 +60,6 @@ RUN groupadd --gid ${TRAVIS_GID} ${TRAVIS_GROUP} || true
4260
RUN useradd -d /travis/home -g ${TRAVIS_GROUP} --uid ${TRAVIS_UID} ${TRAVIS_USER}
4361
USER ${TRAVIS_USER}:${TRAVIS_GROUP}
4462

45-
# Ensure Pants runs under the 2.7.13 interpreter.
46-
ENV PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS="['CPython==2.7.13']"
47-
4863
# Our newly created user is unlikely to have a sane environment: set a locale at least.
4964
ENV LC_ALL="en_US.UTF-8"
5065

build-support/travis/generate_travis_yml.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# GENERATED, DO NOT EDIT!
1616
# To change, edit build-support/travis/travis.yml.mustache and run
1717
# ./pants --quiet run build-support/travis:generate_travis_yml > .travis.yml
18+
#
19+
# Tip: Copy the generated `.travis.yml` into https://yamlvalidator.com to validate the YAML
20+
# and see how the entries resolve to normalized JSON (helpful to debug anchors).
1821
"""
1922

2023

0 commit comments

Comments
 (0)