-
-
Notifications
You must be signed in to change notification settings - Fork 398
Build manylinux1 OS-specific binary wheels in Travis (CI) and publish them to PyPI (CD) #869
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
Merged
jdavid
merged 28 commits into
libgit2:master
from
webknjaz:feature/manylinux1-binary-wheels
Feb 16, 2019
Merged
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b470b1a
let's give this a try
beniwohli 89d62fd
vars
webknjaz 5023308
Rearrange travis config
webknjaz a0c2679
Bump libgit2 source to v0.27
webknjaz 5d184dd
Fix building manylinux1 wheels
webknjaz 94edb05
Don't execute install step in docker jobs
webknjaz fbcef81
Fix referring pip bin var
webknjaz eaedbf8
Fix env vars in travis
webknjaz 976d544
Upgrade PyPy to v6.0
webknjaz 948872c
Run pip in parallel
webknjaz 7a5bc52
Adjust tests to succeed under PyPy v6.0
webknjaz 8db38f7
Put manylinux1 jobs into a separate stage
webknjaz 5f2c250
Add deploy step stub to travis
webknjaz ae1ee1c
Undo async in wheel build script
webknjaz dc801b7
Create wheelhouse dir on build start
webknjaz 548ecf4
Be more precise during wheel processing
webknjaz 518984d
Add a wrapper script for building several archs
webknjaz 029165c
Add a deploy step stub to Travis
webknjaz d9d40d2
Save final wheels to dist dir directly
webknjaz e184187
Add deploy stage conditional stub
webknjaz ee78fde
List the whole wheelhouse folder
webknjaz 6b55b79
List full dist folder in travis
webknjaz b530d20
Copy travis config owner to dist dir
webknjaz 18abf68
Compile libgit2 in threadsafe mode
webknjaz e1ebe52
Compile libgit2 in "Release" build type mode
webknjaz 457b1d1
Detect custom OpenSSL properly
webknjaz 57da1d5
Extend build flags
webknjaz 4a50c76
Build libgit2 with libssh2 v1.8.0
webknjaz 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 hidden or 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 hidden or 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 | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||||
dist: xenial | ||||||
language: python | ||||||
|
||||||
cache: pip | ||||||
|
@@ -7,22 +8,72 @@ python: | |||||
- "3.4" | ||||||
- "3.5" | ||||||
- "3.6" | ||||||
- "pypy" | ||||||
- "3.7" | ||||||
- "pypy2.7-6.0" | ||||||
- "pypy3.5-6.0" | ||||||
|
||||||
matrix: | ||||||
env: | ||||||
global: | ||||||
LIBGIT2: ~/libgit2/_install/ | ||||||
LD_LIBRARY_PATH: ${LIBGIT2}/lib:${LD_LIBRARY_PATH} | ||||||
LIBGIT2_VERSION: "0.27" | ||||||
|
||||||
|
||||||
jobs: | ||||||
include: | ||||||
- python: 3.7 | ||||||
dist: xenial | ||||||
sudo: true | ||||||
- stage: &deploy_stage Publish to PyPI (runs only for tagged commits) | ||||||
name: >- | ||||||
OS-specific manylinux1 wheels | ||||||
python: "3.7" | ||||||
services: | ||||||
- docker | ||||||
install: skip | ||||||
script: &docker-script | ||||||
- travis/build-all-manylinux1-wheels.sh "pygit2" "${LIBGIT2_VERSION}" | ||||||
before_deploy: | ||||||
- ls dist | ||||||
- pip install twine | ||||||
- twine check dist/* | ||||||
deploy: | ||||||
provider: pypi | ||||||
# `skip-cleanup: true` is required to preserve binary wheels, built | ||||||
# inside of manylinux1 docker container during `script` step above. | ||||||
skip-cleanup: true | ||||||
# `skip-existing: true` is required to skip uploading dists, already | ||||||
# present in PYPI instead of failing the whole process. | ||||||
# This happens when other CI (AppVeyor etc.) has already uploaded | ||||||
# the very same dist (usually sdist). | ||||||
skip-existing: true | ||||||
user: jdavid | ||||||
password: | ||||||
# Encrypted with `travis encrypt -r aio-libs/aiohttp --api-endpoint 'https://api.travis-ci.com/'`: | ||||||
secure: >- | ||||||
TODO: REPLACE THIS WITH AN ENCRYPTED PASSWORD | ||||||
# Although Travis CI instructs `setup.py` to build source distribution, | ||||||
# which is default value for distribution option (`distribution: sdist`), | ||||||
# it will also upload all wheels we've previously built in manylinux1 | ||||||
# docker container using `twine upload -r pypi dist/*` command. | ||||||
# Also since commit https://github.com/travis-ci/dpl/commit/90b5e39 | ||||||
# it is default that Travis PYPI provider has `skip_upload_docs: true` | ||||||
# set by default. | ||||||
# Besides above, we don't do cleanup of `dist/*`, because it's being done | ||||||
# by Travis CI PYPI deployment provider after upload, unconditionally. | ||||||
on: | ||||||
tags: true | ||||||
all_branches: true | ||||||
|
||||||
env: LIBGIT2=~/libgit2/_install/ LD_LIBRARY_PATH=~/libgit2/_install/lib | ||||||
|
||||||
before_install: | ||||||
- sudo apt-get install cmake | ||||||
- "./.travis.sh" | ||||||
- ./.travis.sh "${LIBGIT2_VERSION}" | ||||||
|
||||||
install: | ||||||
- pip install . | ||||||
|
||||||
script: | ||||||
- pytest | ||||||
|
||||||
stages: | ||||||
- test | ||||||
- name: *deploy_stage | ||||||
if: 1=1 OR tag IS present OR type IN (cron, api) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jdavid
Suggested change
once password is updated. |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -90,11 +90,10 @@ def test_modify_tag(self): | |
tagger = ('John Doe', '[email protected]', 12347) | ||
|
||
tag = self.repo[TAG_SHA] | ||
error_type = AttributeError if not pypy2 else TypeError | ||
with pytest.raises(error_type): setattr(tag, 'name', name) | ||
with pytest.raises(error_type): setattr(tag, 'target', target) | ||
with pytest.raises(error_type): setattr(tag, 'tagger', tagger) | ||
with pytest.raises(error_type): setattr(tag, 'message', message) | ||
with pytest.raises(AttributeError): setattr(tag, 'name', name) | ||
with pytest.raises(AttributeError): setattr(tag, 'target', target) | ||
with pytest.raises(AttributeError): setattr(tag, 'tagger', tagger) | ||
with pytest.raises(AttributeError): setattr(tag, 'message', message) | ||
|
||
def test_get_object(self): | ||
repo = self.repo | ||
|
This file contains hidden or 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,51 @@ | ||
#! /usr/bin/env bash | ||
if [ -n "$DEBUG" ] | ||
then | ||
set -x | ||
fi | ||
|
||
package_name="$1" | ||
LIBGIT2_VERSION="$2" | ||
|
||
set -euo pipefail | ||
|
||
if [ -z "$package_name" ] | ||
then | ||
>&2 echo "Please pass package name as a first argument of this script ($0)" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$LIBGIT2_VERSION" ] | ||
then | ||
>&2 echo "Please pass libgit2 version as a second argument of this script ($0)" | ||
exit 1 | ||
fi | ||
|
||
manylinux1_image_prefix="quay.io/pypa/manylinux1_" | ||
manylinux1_image_prefix="pyca/cryptography-manylinux1:" | ||
dock_ext_args="" | ||
declare -A docker_pull_pids=() # This syntax requires at least bash v4 | ||
|
||
for arch in x86_64 i686 | ||
do | ||
docker pull "${manylinux1_image_prefix}${arch}" & | ||
docker_pull_pids[$arch]=$! | ||
done | ||
|
||
for arch in x86_64 i686 | ||
do | ||
echo | ||
echo | ||
arch_pull_pid=${docker_pull_pids[$arch]} | ||
echo Waiting for docker pull PID $arch_pull_pid to complete downloading container for $arch arch... | ||
wait $arch_pull_pid # await for docker image for current arch to be pulled from hub | ||
[ $arch == "i686" ] && dock_ext_args="linux32" | ||
|
||
echo Building wheel for $arch arch | ||
docker run --rm -v `pwd`:/io "${manylinux1_image_prefix}${arch}" $dock_ext_args /io/travis/build-manylinux1-wheels.sh "$package_name" "$LIBGIT2_VERSION" & | ||
|
||
dock_ext_args="" # Reset docker args, just in case | ||
done | ||
wait | ||
|
||
set +u |
This file contains hidden or 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,104 @@ | ||
#!/usr/bin/env bash | ||
if [ -n "$DEBUG" ] | ||
then | ||
set -x | ||
fi | ||
|
||
DIST_NAME="$1" | ||
LIBGIT2_VERSION="$2" | ||
|
||
set -euo pipefail | ||
|
||
if [ -z "$DIST_NAME" ] | ||
then | ||
>&2 echo "Please pass package name as a first argument of this script ($0)" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$LIBGIT2_VERSION" ] | ||
then | ||
>&2 echo "Please pass libgit2 version as a second argument of this script ($0)" | ||
exit 1 | ||
fi | ||
|
||
PYTHONS=`ls /opt/python/` | ||
|
||
SRC_DIR=/io | ||
BUILD_DIR=`mktemp -d "/tmp/${DIST_NAME}-manylinux1-build.XXXXXXXXXX"` | ||
LIBGIT2_CLONE_DIR="${BUILD_DIR}/libgit2" | ||
LIBGIT2_BUILD_DIR="${LIBGIT2_CLONE_DIR}/build" | ||
export LIBGIT2="${LIBGIT2_CLONE_DIR}/_install" | ||
|
||
ORIG_WHEEL_DIR="${BUILD_DIR}/original-wheelhouse" | ||
WHEEL_DEP_DIR="${BUILD_DIR}/deps-wheelhouse" | ||
WHEELHOUSE_DIR="${SRC_DIR}/dist" | ||
|
||
mkdir -p "$WHEELHOUSE_DIR" | ||
|
||
export PYCA_OPENSSL_PATH=/opt/pyca/cryptography/openssl | ||
export OPENSSL_PATH=/opt/openssl | ||
|
||
export CFLAGS="-I${PYCA_OPENSSL_PATH}/include -I${OPENSSL_PATH}/include" | ||
export LDFLAGS="-L${PYCA_OPENSSL_PATH}/lib -L${OPENSSL_PATH}/lib -L/usr/local/lib/" | ||
export LD_LIBRARY_PATH="${LIBGIT2}/lib:$LD_LIBRARY_PATH" | ||
|
||
ARCH=`uname -m` | ||
|
||
|
||
>&2 echo Installing system deps... | ||
# Install a system package required by our library | ||
# libgit2 needs cmake 2.8, which can be found in EPEL | ||
yum -y install \ | ||
git libssh2-devel libffi-devel \ | ||
openssl-devel pkgconfig \ | ||
cmake28 | ||
|
||
>&2 echo downloading source of libgit2 v${LIBGIT2_VERSION}: | ||
git clone \ | ||
--depth=1 \ | ||
-b "maint/v${LIBGIT2_VERSION}" \ | ||
https://github.com/libgit2/libgit2.git \ | ||
"${LIBGIT2_CLONE_DIR}" | ||
|
||
>&2 echo Building libgit2... | ||
mkdir -p "${LIBGIT2_BUILD_DIR}" | ||
pushd "${LIBGIT2_BUILD_DIR}" | ||
cmake28 "${LIBGIT2_CLONE_DIR}" -DCMAKE_INSTALL_PREFIX="${LIBGIT2}" -DBUILD_CLAR=OFF | ||
cmake28 --build "${LIBGIT2_BUILD_DIR}" --target install | ||
popd | ||
|
||
>&2 echo Building wheels: | ||
for PIP_BIN in /opt/python/*/bin/pip; do | ||
>&2 echo Using "${PIP_BIN}"... | ||
${PIP_BIN} wheel "${SRC_DIR}" -w "${ORIG_WHEEL_DIR}" | ||
done | ||
|
||
>&2 echo Reparing wheels: | ||
# Bundle external shared libraries into the wheels | ||
for PY in $PYTHONS; do | ||
for whl in ${ORIG_WHEEL_DIR}/${DIST_NAME}-*-${PY}-linux_${ARCH}.whl; do | ||
>&2 echo Reparing "${whl}"... | ||
auditwheel repair "${whl}" -w ${WHEELHOUSE_DIR} | ||
done | ||
done | ||
|
||
# Download deps | ||
>&2 echo Downloading dependencies: | ||
for PY in $PYTHONS; do | ||
PIP_BIN="/opt/python/${PY}/bin/pip" | ||
WHEEL_FILE=`ls ${WHEELHOUSE_DIR}/${DIST_NAME}-*-${PY}-manylinux1_${ARCH}.whl` | ||
>&2 echo Downloading ${WHEEL_FILE} deps using ${PIP_BIN}... | ||
${PIP_BIN} download -d "${WHEEL_DEP_DIR}" "${WHEEL_FILE}" | ||
done | ||
|
||
# Install packages | ||
>&2 echo Testing wheels installation: | ||
for PIP_BIN in /opt/python/*/bin/pip; do | ||
>&2 echo Using ${PIP_BIN}... | ||
${PIP_BIN} install "${DIST_NAME}" --no-index -f ${WHEEL_DEP_DIR} & | ||
done | ||
wait | ||
|
||
chown -R 1000:1000 ${WHEELHOUSE_DIR} | ||
>&2 echo Final OS-specific wheels for ${DIST_NAME}: | ||
ls -l ${WHEELHOUSE_DIR}/*.whl |
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.
@jdavid please generate the encrypted string using
travis encrypt -r libgit2/pygit2
command.And then you can use this page to update in via UI right in this PR: https://github.com/webknjaz/pygit2/edit/feature/manylinux1-binary-wheels/.travis.yml?pr=%2Flibgit2%2Fpygit2%2Fpull%2F869