-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Specify ABI for pantsbuild.pants wheel and build with both UCS2 and UCS4 #7235
Merged
Eric-Arellano
merged 86 commits into
pantsbuild:master
from
Eric-Arellano:py2-wheels-abi-specified
Mar 9, 2019
Merged
Changes from all commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
a02dde1
Add ext_modules to BUILD entry
Eric-Arellano 1e83f37
Setup UCS2 vs UCS4 travis shards
Eric-Arellano f7472aa
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 28b9e8b
Turn on PEX_VERBOSE for OSX ucs4 shard
Eric-Arellano e87f567
Fix typo in Dockerfile path
Eric-Arellano 170e9c8
Install OpenSSL on OSX UCS4 shard
Eric-Arellano 8d69dc2
Improve naming of Build Wheels shards
Eric-Arellano 6ecb550
Fix Dockerfile copyright year and add comment
Eric-Arellano 7c17c0a
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano edf81ef
Run PEX with -v*9
Eric-Arellano 0b59e46
Fix gcc no input file issues by passing dummy file
Eric-Arellano ab534e2
Bootstrap Pants when using new Python install
Eric-Arellano fb9ef9b
Revert "Run PEX with -v*9"
Eric-Arellano ad45b2d
Revert "Turn on PEX_VERBOSE for OSX ucs4 shard"
Eric-Arellano dc36d94
Also deduplicate Pyenv env vars for OSX
Eric-Arellano 513cd50
release.sh still needs to run from PEX
Eric-Arellano 0da5f91
Stop pulling down PEX
Eric-Arellano 621137e
Fix improper call to {osx,linux}_config_env
Eric-Arellano 38e1cf7
Remove unncessary RUN_PANTS_FROM_PEX=0
Eric-Arellano 7da092b
Fix platform default shards bootstrapping
Eric-Arellano c9e1650
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 2cd72e4
Add back logging to debug osx ucs4
Eric-Arellano e502f58
Fix linux ucs4 stage being overriden to cron instead of test
Eric-Arellano 04c4ee0
Move debugging to proper location
Eric-Arellano 78a1aa9
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 48ef4dd
Squashed commit of the following:
Eric-Arellano 8428376
Fix typo from squashed pex-constraints
Eric-Arellano 223541e
Fix Linux UCS2 using 2.7.13 with UCS4 instead of UCS2 sometimes
Eric-Arellano f530843
Move unit tests above wheel building shards
Eric-Arellano 1be9e90
Squashed commit of the following:
Eric-Arellano 225f153
Remove bad merge lines
Eric-Arellano 8402c1f
Ensure Linux UCS2 always uses Py2.7.15 (UCS2)
Eric-Arellano b9efbf0
Also set PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS for OSX
Eric-Arellano f810849
Move interpreter constraints to Docker env entry
Eric-Arellano c3dd843
Improve wording.
Eric-Arellano 49fe576
Stop hardcoding interpreter constraints
Eric-Arellano 8dd215d
Allow user to set $PY in ci.sh
Eric-Arellano 2166efe
Set $PY to disambiguate which Py2.7 version to use
Eric-Arellano 3bf2d28
Add Pyenv back to Travis path
Eric-Arellano 373ffee
Configure PEX_PYTHON on linux UCS2
Eric-Arellano 0d25bcc
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 4cb6cae
Squashed commit of the following:
Eric-Arellano efaae09
Add debugging to release.sh for linux ucs2
Eric-Arellano 8104abc
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 6272e78
Try setting PY for release.sh script
Eric-Arellano b755119
Temporarily move Linux UCS2 to top of CI
Eric-Arellano aedf0ce
Try setting PY for bootstrap also
Eric-Arellano 9798a4b
See if reverting the stages fixes bad interpreter resolve
Eric-Arellano 01b59f0
Also remove PY variable from Linux UCS2
Eric-Arellano a4cc818
Add back PY to linux UCS2 and skip bootstrap
Eric-Arellano 91d7dd0
Allow ./pants2 to have preset interpreter constraints
Eric-Arellano d38d80f
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 23bb6fd
Test if removing Conan default interpreter constraints fixes bootstrap
Eric-Arellano 2057c9a
Properly test that we're building the right UCS
Eric-Arellano e157960
Allow user to predefine $PY + add interpreter constraints to release.sh
Eric-Arellano 145f484
Remove comment about Python 3
Eric-Arellano 64d5d7f
Use PEX_PYTHON_PATH over PEX_PYTHON
Eric-Arellano aec536d
Update Dockerfile comment to mention release.sh changes
Eric-Arellano d45c3fc
Also ensure Linux UCS4 and OSX UCS2 have correct encoding
Eric-Arellano f961150
Remove bad ./pants.pex -c call
Eric-Arellano bd15818
Ensure ./pants.pex is correct by inspecting PEX-INFO
Eric-Arellano 0ebb0d8
Squashed commit of the following:
Eric-Arellano 270a0e7
Install unzip on Docker images
Eric-Arellano 67d7fdd
Revert Conan interpreter change
Eric-Arellano dd930ee
Make new check_pants_pex_abi.sh script
Eric-Arellano 489a3ed
Use `set -x` for check abi script
Eric-Arellano 58b09f9
Also run OSX UCS4 in bootstrap stage
Eric-Arellano a432f6c
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 28d9ac9
Fix Centos6 issue
Eric-Arellano 8e8164e
Restore Python 2 bootstrap shards
Eric-Arellano 6a06eec
Remove debugging code
Eric-Arellano 893be87
Remove bad pants.pex
Eric-Arellano 33fd022
Restore full CI suite
Eric-Arellano a3d5ec5
Add back debugging and limited CI
Eric-Arellano 7eb2741
Revert "Add back debugging and limited CI"
Eric-Arellano ab502fd
Move up check abi script's opt parsing
Eric-Arellano cbd325e
Must source common.sh before calling die
Eric-Arellano 0544947
Port check_pants_pex_abi.sh to Python
Eric-Arellano 519ce59
Improve release.sh check for valid interpreter
Eric-Arellano 23fb23b
Explain better why we duplicate travis_ci/Dockerfile
Eric-Arellano ee030c7
Add comments to pants/BUILD
Eric-Arellano c7ae6c4
Merge branch 'master' of github.com:pantsbuild/pants into py2-wheels-…
Eric-Arellano 463f38a
Extract out launch_docker_image
Eric-Arellano d64845f
Restore env_osx_with_pyenv being multiline
Eric-Arellano 67c4557
Remove unused anchor and import
Eric-Arellano 971eadf
Add success message and improve missing pants.pex for new check script
Eric-Arellano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python2.7 | ||
Eric-Arellano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# coding=utf-8 | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
# Check that the ./pants.pex was built using the passed abi specification. | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
import argparse | ||
import json | ||
import os.path | ||
import zipfile | ||
|
||
|
||
RED = "\033[31m" | ||
BLUE = "\033[34m" | ||
RESET = "\033[0m" | ||
|
||
|
||
def main(): | ||
if not os.path.isfile("pants.pex"): | ||
die("pants.pex not found! Ensure you are in the repository root, then run " \ | ||
"'./build-support/bin/ci.sh -b' to bootstrap pants.pex with Python 3 or " \ | ||
"'./build-support/bin/ci.sh -2b' to bootstrap pants.pex with Python 2.") | ||
expected_abi = create_parser().parse_args().abi | ||
with zipfile.ZipFile("pants.pex", "r") as pex: | ||
with pex.open("PEX-INFO", "r") as pex_info: | ||
pex_info_content = str(pex_info.readline()) | ||
parsed_abis = { | ||
parse_abi_from_filename(filename) | ||
for filename in json.loads(pex_info_content)["distributions"].keys() | ||
if parse_abi_from_filename(filename) != "none" | ||
} | ||
if len(parsed_abis) < 1: | ||
die("No abi tag found. Expected: {}.".format(expected_abi)) | ||
elif len(parsed_abis) > 1: | ||
die("Multiple abi tags found. Expected: {}, found: {}.".format(expected_abi, parsed_abis)) | ||
found_abi = list(parsed_abis)[0] | ||
if found_abi != expected_abi: | ||
die("pants.pex was built with the incorrect ABI. Expected: {}, found: {}.".format(expected_abi, found_abi)) | ||
success("Success. As expected, pants.pex was built with the ABI {}.".format(expected_abi)) | ||
|
||
Eric-Arellano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def create_parser(): | ||
parser = argparse.ArgumentParser( | ||
description="Check that ./pants.pex was built using the passed abi specification." | ||
) | ||
parser.add_argument("abi", help="The expected abi, e.g. `cp27m` or `abi3`") | ||
return parser | ||
|
||
|
||
def parse_abi_from_filename(filename): | ||
"""This parses out the abi from a wheel filename. | ||
|
||
For example, `configparser-3.5.0-py2-abi3-any.whl` would return `abi3`. | ||
See https://www.python.org/dev/peps/pep-0425/#use for how wheel filenames are defined.""" | ||
return filename.split("-")[-2] | ||
|
||
|
||
def success(message): | ||
print("{}{}{}".format(BLUE, message, RESET)) | ||
|
||
|
||
def die(message): | ||
raise SystemExit("{}{}{}".format(RED, message, RESET)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
# NB: this file duplicates travis_ci/Dockerfile, except it installs Python 2.7 with UCS2. | ||
# We do not include this change directly in centos6/Dockerfile nor in travis_ci/Dockerfile | ||
# because we only want access to this Python interpreter in the Build Wheels Linux UCS2 shard, | ||
# so it is not helpful to other shards. Rather, it would make those shards more finicky to deal | ||
# with by resulting in two Python 2.7 installs: system vs. pyenv. | ||
|
||
# Use our custom Centos6 image for binary compatibility with old linux distros. | ||
FROM pantsbuild/centos6:latest | ||
|
||
# Note we use 2.7.15, rather than 2.7.13, as the centos6 image already comes with 2.7.13 | ||
# installed, which uses UCS4 instead of UCS2. This allows us to disambiguate which Python 2 | ||
# 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 | ||
# 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 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}' | ||
ENV PATH "${PYENV_ROOT}/shims:${PATH}" | ||
ENV PY "${PYENV_ROOT}/shims/python2.7" | ||
ENV PEX_PYTHON_PATH "${PYENV_ROOT}/shims/python2.7" | ||
|
||
# Setup mount points for the travis ci user & workdir. | ||
VOLUME /travis/home | ||
VOLUME /travis/workdir | ||
|
||
# Setup a non-root user to execute the build under (avoids problems with npm install). | ||
ARG TRAVIS_USER=travis_ci | ||
ARG TRAVIS_UID=1000 | ||
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} | ||
USER ${TRAVIS_USER}:${TRAVIS_GROUP} | ||
|
||
# Our newly created user is unlikely to have a sane environment: set a locale at least. | ||
ENV LC_ALL="en_US.UTF-8" | ||
|
||
WORKDIR /travis/workdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PATH="/usr/local/opt/openssl/bin:$PATH" | ||
LDFLAGS="-L/usr/local/opt/openssl/lib" | ||
CPPFLAGS="-I/usr/local/opt/openssl/include" | ||
PYENV_ROOT="${HOME}/.pyenv" | ||
PATH="${PYENV_ROOT}/shims:${PATH}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good comment!