Skip to content

Commit cba72ae

Browse files
Ensure Python 3.6 or 3.7 is installed on all CI shards (#7483)
### Problem Once all CI shards are guaranteed to have Python 3, we can port our more complex `build-support` scripts to Python 3, which will allow us to reduce technical debt and to bring benefits like better argument parsing. In particular, we want to be able to use Python 3 in those scripts so that we can use `subprocess.run()`. ### Solution For Linux, Travis pre-installs Python 3.6 and 3.7. We simply tell Travis we want those installed, and then set `pyenv global` to resolve everything for no performance cost. OSX shards do not have Python 3 installed by default (at least for certain `osx_images`), so we use Pyenv to install on all shards. This is no longer very costly to do so thanks to caching Pyenv through #7470. ### Result All shards now have Python 3.6 or 3.7. Once we update the Centos6 Docker image in #7064, every where in CI will have Python 3. We can in the meantime now start porting scripts if we are confident they are never used by Docker.
1 parent 1f23088 commit cba72ae

File tree

4 files changed

+90
-97
lines changed

4 files changed

+90
-97
lines changed

.travis.yml

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ base_linux_config: &base_linux_config
131131
os: linux
132132
dist: xenial
133133
sudo: required
134+
python:
135+
- "2.7"
136+
- "3.6"
137+
- "3.7"
134138
addons:
135139
apt:
136140
packages:
@@ -146,20 +150,18 @@ base_linux_config: &base_linux_config
146150
language: python
147151
before_install:
148152
- ./build-support/bin/install_aws_cli_for_ci.sh
153+
- pyenv global 2.7.15 3.6.7 3.7.1
149154
after_failure:
150155
- ./build-support/bin/ci-failure.sh
151156

152157
py27_linux_config: &py27_linux_config
153158
<<: *base_linux_config
154-
python: &python2_version "2.7"
155159

156160
py36_linux_config: &py36_linux_config
157161
<<: *base_linux_config
158-
python: "3.6"
159162

160163
py37_linux_config: &py37_linux_config
161164
<<: *base_linux_config
162-
python: "3.7"
163165

164166
base_linux_test_config: &base_linux_test_config
165167
<<: *base_linux_config
@@ -169,6 +171,7 @@ base_linux_test_config: &base_linux_test_config
169171
- JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
170172
- sudo sysctl fs.inotify.max_user_watches=524288
171173
- ./build-support/bin/install_aws_cli_for_ci.sh
174+
- pyenv global 2.7.15 3.6.7 3.7.1
172175
before_script:
173176
- *aws_get_pants_pex
174177

@@ -197,37 +200,34 @@ py37_linux_test_config: &py37_linux_test_config
197200
base_osx_config: &base_osx_config
198201
os: osx
199202
language: generic
203+
addons:
204+
brew:
205+
packages:
206+
- openssl
200207
before_install:
201208
- curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 -o /usr/local/bin/jq
202209
- chmod 755 /usr/local/bin/jq
203210
- ./build-support/bin/install_aws_cli_for_ci.sh
211+
- ./build-support/bin/install_python_for_ci.sh "${PYENV_PY36_VERSION}"
204212

205213
py27_osx_config: &py27_osx_config
206214
<<: *base_osx_config
215+
env:
216+
- &py27_osx_config_env >
217+
PATH="/usr/local/opt/openssl/bin:$PATH"
218+
LDFLAGS="-L/usr/local/opt/openssl/lib"
219+
CPPFLAGS="-I/usr/local/opt/openssl/include"
207220

208221
py36_osx_config: &py36_osx_config
209222
<<: *base_osx_config
210-
addons:
211-
brew:
212-
packages: &py36_osx_config_brew_packages
213-
- openssl
214223
env:
215224
- &py36_osx_config_env >
216225
PATH="/usr/local/opt/openssl/bin:$PATH"
217226
LDFLAGS="-L/usr/local/opt/openssl/lib"
218227
CPPFLAGS="-I/usr/local/opt/openssl/include"
219-
before_install:
220-
- curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 -o /usr/local/bin/jq
221-
- chmod 755 /usr/local/bin/jq
222-
- ./build-support/bin/install_aws_cli_for_ci.sh
223-
- ./build-support/bin/install_python_for_ci.sh "${PYENV_PY36_VERSION}"
224228

225229
py37_osx_config: &py37_osx_config
226230
<<: *base_osx_config
227-
addons:
228-
brew:
229-
packages: &py37_osx_config_brew_packages
230-
- openssl
231231
env:
232232
- &py37_osx_config_env >
233233
PATH="/usr/local/opt/openssl/bin:$PATH"
@@ -251,7 +251,11 @@ py27_osx_test_config: &py27_osx_test_config
251251
<<: *base_osx_test_config
252252
stage: *test_cron
253253
env:
254-
- &py27_osx_test_config_env BOOTSTRAPPED_PEX_KEY_SUFFIX=py27.osx
254+
- &py27_osx_test_config_env >
255+
PATH="/usr/local/opt/openssl/bin:$PATH"
256+
LDFLAGS="-L/usr/local/opt/openssl/lib"
257+
CPPFLAGS="-I/usr/local/opt/openssl/include"
258+
BOOTSTRAPPED_PEX_KEY_SUFFIX=py27.osx
255259

256260
py36_osx_test_config: &py36_osx_test_config
257261
<<: *py36_osx_config
@@ -276,15 +280,23 @@ py37_osx_test_config: &py37_osx_test_config
276280
BOOTSTRAPPED_PEX_KEY_SUFFIX=py37.osx
277281

278282
linux_with_fuse: &linux_with_fuse
283+
os: linux
284+
dist: xenial
285+
sudo: required
279286
before_install:
280287
- PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin":$PATH
281288
- JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
282289
- sudo sysctl fs.inotify.max_user_watches=524288
283290
- ./build-support/bin/install_aws_cli_for_ci.sh
291+
- pyenv global 2.7.15 3.6.7 3.7.1
284292
- sudo apt-get install -y pkg-config fuse libfuse-dev
285293
- sudo modprobe fuse
286294
- sudo chmod 666 /dev/fuse
287295
- sudo chown root:$USER /etc/fuse.conf
296+
python:
297+
- "2.7"
298+
- "3.6"
299+
- "3.7"
288300

289301
travis_docker_image: &travis_docker_image
290302
services:
@@ -379,6 +391,7 @@ py27_osx_build_engine: &py27_osx_build_engine
379391
<<: *base_osx_build_engine
380392
name: "Build OSX native engine and pants.pex (Py2.7 PEX)"
381393
env:
394+
- *py27_osx_config_env
382395
- PREPARE_DEPLOY=1
383396
- CACHE_NAME=osxpexbuild.py27
384397
- BOOTSTRAPPED_PEX_KEY_SUFFIX=py27.osx
@@ -449,32 +462,27 @@ py37_lint: &py37_lint
449462
# Rust lints
450463
# -------------------------------------------------------------------------
451464

452-
linux_rust_clippy: &linux_rust_clippy
465+
base_rust_lints: &base_rust_lints
453466
<<: *linux_with_fuse
467+
468+
linux_rust_clippy: &linux_rust_clippy
469+
<<: *base_rust_lints
454470
<<: *native_engine_cache_config
455471
name: "Linux Rust Clippy (No PEX)"
456472
env:
457473
- CACHE_NAME=linuxclippy
458-
os: linux
459-
dist: xenial
460-
sudo: required
461474
stage: *test
462-
language: python
463-
python: "3.6"
464475
before_script:
465476
- ulimit -c unlimited
466477
- ulimit -n 8192
467478
script:
468479
- ./build-support/bin/travis-ci.sh -s
469480

470481
cargo_audit: &cargo_audit
471-
<<: *linux_with_fuse
482+
<<: *base_rust_lints
472483
name: "Cargo audit (No PEX)"
473484
env:
474485
- CACHE_NAME=linuxcargoaudit
475-
os: linux
476-
dist: xenial
477-
sudo: required
478486
stage: *test_cron
479487
script:
480488
- ./build-support/bin/travis-ci.sh -a
@@ -581,25 +589,18 @@ py27_osx_build_wheels_ucs4: &py27_osx_build_wheels_ucs4
581589
<<: *base_osx_build_wheels
582590
<<: *native_engine_cache_config
583591
name: "Build wheels - OSX and cp27mu (UCS4)"
584-
addons:
585-
brew:
586-
packages:
587-
- openssl
588592
env:
593+
- *py27_osx_config_env
589594
- *base_build_wheels_env
590595
- CACHE_NAME=osxwheelsbuild.ucs4
591-
- >
592-
PATH="/usr/local/opt/openssl/bin:$PATH"
593-
LDFLAGS="-L/usr/local/opt/openssl/lib"
594-
CPPFLAGS="-I/usr/local/opt/openssl/include"
595596
- PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs4
596597
# We set $PY to ensure the UCS4 interpreter is used when bootstrapping the PEX.
597598
- PY=${PYENV_ROOT}/shims/python2.7
598599
before_install:
599600
- curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64 -o /usr/local/bin/jq
600601
- chmod 755 /usr/local/bin/jq
601602
- ./build-support/bin/install_aws_cli_for_ci.sh
602-
- ./build-support/bin/install_python_for_ci.sh 2.7.13
603+
- ./build-support/bin/install_python_for_ci.sh 2.7.13 ${PYENV_PY36_VERSION}
603604
script:
604605
- ./build-support/bin/ci.sh -2b
605606
- ./build-support/bin/check_pants_pex_abi.py cp27mu
@@ -627,38 +628,35 @@ base_rust_tests: &base_rust_tests
627628
before_script:
628629
- ulimit -c unlimited
629630
- ulimit -n 8192
631+
script:
632+
- ./build-support/bin/travis-ci.sh -e
630633

631634
linux_rust_tests: &linux_rust_tests
632635
<<: *base_rust_tests
633636
<<: *linux_with_fuse
634637
name: "Rust tests - Linux (No PEX)"
635638
env:
636639
- CACHE_NAME=linuxrusttests
637-
os: linux
638-
dist: xenial
639-
sudo: required
640-
language: python
641-
python: "3.6"
642-
script:
643-
- ./build-support/bin/travis-ci.sh -e
644640

645641
osx_rust_tests: &osx_rust_tests
646642
<<: *base_rust_tests
647643
name: "Rust tests - OSX (No PEX)"
648-
env:
649-
- CACHE_NAME=macosrusttests
650644
os: osx
651645
# Fuse actually works on this image. It hangs on many others.
652646
osx_image: xcode8.3
653647
addons:
654648
homebrew:
655649
casks:
650+
- openssl
656651
- osxfuse
657-
script:
658-
# N.B. We run this with Python 2 because this osx_image does not have
659-
# Python 3.6 or 3.7 in its environment. We do not care which Python version
660-
# we use and do not want to incur the cost of using pyenv to get 3.6 or 3.7.
661-
- ./build-support/bin/travis-ci.sh -e2
652+
before_install:
653+
- ./build-support/bin/install_python_for_ci.sh "${PYENV_PY36_VERSION}"
654+
env:
655+
- >
656+
PATH="/usr/local/opt/openssl/bin:$PATH"
657+
LDFLAGS="-L/usr/local/opt/openssl/lib"
658+
CPPFLAGS="-I/usr/local/opt/openssl/include"
659+
- CACHE_NAME=macosrusttests
662660

663661
# -------------------------------------------------------------------------
664662
# OSX sanity checks

build-support/bin/install_python_for_ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set -euo pipefail
1010

1111
source build-support/common.sh
1212

13-
PYTHON_VERSIONS="$@"
13+
PYTHON_VERSIONS=("$@")
1414

1515
if [[ -z "${PYENV_ROOT:+''}" ]]; then
1616
die "Caller of the script must set the env var PYENV_ROOT."

build-support/travis/before_install_linux.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
# files in the working copy. }}
55
- sudo sysctl fs.inotify.max_user_watches=524288
66
- ./build-support/bin/install_aws_cli_for_ci.sh
7+
- pyenv global 2.7.15 3.6.7 3.7.1

0 commit comments

Comments
 (0)