Skip to content

Commit 942ef20

Browse files
committed
Fix building manylinux1 wheels
1 parent 43b0458 commit 942ef20

File tree

4 files changed

+95
-27
lines changed

4 files changed

+95
-27
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/build/
44
/dist/
55
/docs/_build/
6+
/wheelhouse/
67
/MANIFEST
78
__pycache__/
89
*.egg-info

.travis.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/bin/sh
22

3+
LIBGIT2_VERSION="$1"
4+
if [ -z "$LIBGIT2_VERSION" ]
5+
then
6+
>&2 echo "Please pass libgit2 version as a first argument of this script ($0)"
7+
exit 1
8+
fi
9+
310
cd ~
411

5-
git clone --depth=1 -b maint/v0.27 https://github.com/libgit2/libgit2.git
12+
git clone --depth=1 -b "maint/v${LIBGIT2_VERSION}" https://github.com/libgit2/libgit2.git
613
cd libgit2/
714

815
mkdir build && cd build

.travis.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
global:
1717
LIBGIT2: /libgit2/_install/
1818
LD_LIBRARY_PATH: ~/libgit2/_install/lib
19+
LIBGIT2_VERSION: "0.27"
1920

2021

2122
.mixins:
@@ -25,9 +26,10 @@ env:
2526
services:
2627
- docker
2728
env:
28-
DOCKER_IMAGE: quay.io/pypa/manylinux1_x86_64
29+
# DOCKER_IMAGE: quay.io/pypa/manylinux1_x86_64
30+
DOCKER_IMAGE: pyca/cryptography-manylinux1:x86_64
2931
script: &docker-script
30-
- docker run --rm -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/travis/build-manylinux1-wheels.sh
32+
- docker run --rm -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/travis/build-manylinux1-wheels.sh pygit2 "${LIBGIT2_VERSION}"
3133
- ls wheelhouse/
3234

3335

@@ -36,13 +38,14 @@ jobs:
3638
- <<: *docker-job
3739
- <<: *docker-job
3840
env:
39-
DOCKER_IMAGE: quay.io/pypa/manylinux1_i686
41+
# DOCKER_IMAGE: quay.io/pypa/manylinux1_i686
42+
DOCKER_IMAGE: pyca/cryptography-manylinux1:i686
4043
PRE_CMD: linux32
4144

4245

4346
before_install:
4447
- sudo apt-get install cmake
45-
- "./.travis.sh"
48+
- ./.travis.sh "${LIBGIT2_VERSION}"
4649

4750
install:
4851
- pip install .

travis/build-manylinux1-wheels.sh

+79-22
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,97 @@
11
#!/usr/bin/env bash
2+
if [ -n "$DEBUG" ]
3+
then
4+
set -x
5+
fi
26

3-
set -e -x
4-
CURDIR=`pwd`
7+
DIST_NAME="$1"
8+
LIBGIT2_VERSION="$2"
59

6-
# Install a system package required by our library
7-
yum -y install git libssh2-devel libffi-devel openssl-devel pkgconfig
10+
set -euo pipefail
811

9-
# libgit2 needs cmake 2.8, which can be found in EPEL
12+
if [ -z "$DIST_NAME" ]
13+
then
14+
>&2 echo "Please pass package name as a first argument of this script ($0)"
15+
exit 1
16+
fi
17+
18+
if [ -z "$LIBGIT2_VERSION" ]
19+
then
20+
>&2 echo "Please pass libgit2 version as a second argument of this script ($0)"
21+
exit 1
22+
fi
1023

11-
yum -y install cmake28
24+
PYTHONS=`ls /opt/python/`
1225

13-
git clone --depth=1 -b maint/v0.27 https://github.com/libgit2/libgit2.git
14-
cd libgit2/
26+
SRC_DIR=/io
27+
BUILD_DIR=`mktemp -d "/tmp/${DIST_NAME}-manylinux1-build.XXXXXXXXXX"`
28+
LIBGIT2_CLONE_DIR="${BUILD_DIR}/libgit2"
29+
LIBGIT2_BUILD_DIR="${LIBGIT2_CLONE_DIR}/build"
30+
export LIBGIT2="${LIBGIT2_CLONE_DIR}/_install"
1531

32+
ORIG_WHEEL_DIR="${BUILD_DIR}/original-wheelhouse"
33+
WHEEL_DEP_DIR="${BUILD_DIR}/deps-wheelhouse"
34+
WHEELHOUSE_DIR="${SRC_DIR}/wheelhouse"
1635

17-
mkdir build && cd build
18-
cmake28 .. -DCMAKE_INSTALL_PREFIX=../_install -DBUILD_CLAR=OFF
19-
cmake28 --build . --target install
20-
export LIBGIT2=$CURDIR/libgit2/_install/
21-
export LD_LIBRARY_PATH=$CURDIR/libgit2/_install/lib
36+
export PYCA_OPENSSL_PATH=/opt/pyca/cryptography/openssl
37+
export OPENSSL_PATH=/opt/openssl
2238

23-
mkdir -p wheelhouse
39+
export CFLAGS="-I${PYCA_OPENSSL_PATH}/include -I${OPENSSL_PATH}/include"
40+
export LDFLAGS="-L${PYCA_OPENSSL_PATH}/lib -L${OPENSSL_PATH}/lib -L/usr/local/lib/"
41+
export LD_LIBRARY_PATH="${LIBGIT2}/lib:$LD_LIBRARY_PATH"
2442

25-
# Compile wheels
26-
for PYBIN in /opt/python/*/bin; do
27-
${PYBIN}/pip wheel /io/ -w wheelhouse/
43+
44+
>&2 echo Installing system deps...
45+
# Install a system package required by our library
46+
# libgit2 needs cmake 2.8, which can be found in EPEL
47+
yum -y install \
48+
git libssh2-devel libffi-devel \
49+
openssl-devel pkgconfig \
50+
cmake28
51+
52+
>&2 echo downloading source of libgit2 v${LIBGIT2_VERSION}:
53+
git clone \
54+
--depth=1 \
55+
-b "maint/v${LIBGIT2_VERSION}" \
56+
https://github.com/libgit2/libgit2.git \
57+
"${LIBGIT2_CLONE_DIR}"
58+
59+
>&2 echo Building libgit2...
60+
mkdir -p "${LIBGIT2_BUILD_DIR}"
61+
pushd "${LIBGIT2_BUILD_DIR}"
62+
cmake28 "${LIBGIT2_CLONE_DIR}" -DCMAKE_INSTALL_PREFIX="${LIBGIT2}" -DBUILD_CLAR=OFF
63+
cmake28 --build "${LIBGIT2_BUILD_DIR}" --target install
64+
popd
65+
66+
>&2 echo Building wheels:
67+
for PIP_BIN in /opt/python/*/bin/pip; do
68+
>&2 echo Using "${whl}"...
69+
${PIP_BIN} wheel "${SRC_DIR}" -w "${ORIG_WHEEL_DIR}"
2870
done
2971

72+
>&2 echo Reparing wheels:
3073
# Bundle external shared libraries into the wheels
31-
for whl in wheelhouse/pygit*.whl; do
32-
auditwheel repair $whl -w /io/wheelhouse/
74+
for whl in ${ORIG_WHEEL_DIR}/${DIST_NAME}*.whl; do
75+
>&2 echo Reparing "${whl}"...
76+
auditwheel repair "${whl}" -w ${WHEELHOUSE_DIR}
77+
done
78+
79+
# Download deps
80+
>&2 echo Downloading dependencies:
81+
for PY in $PYTHONS; do
82+
PIP_BIN="/opt/python/${PY}/bin/pip"
83+
WHEEL_FILE=`ls ${WHEELHOUSE_DIR}/${DIST_NAME}-*-${PY}-manylinux1_*.whl`
84+
>&2 echo Downloading ${WHEEL_FILE} deps using ${PIP_BIN}...
85+
${PIP_BIN} download -d "${WHEEL_DEP_DIR}" "${WHEEL_FILE}"
3386
done
3487

3588
# Install packages
36-
for PYBIN in /opt/python/*/bin/; do
37-
${PYBIN}/pip install pygit2 --no-index -f /io/wheelhouse
89+
>&2 echo Testing wheels installation:
90+
for PIP_BIN in /opt/python/*/bin/pip; do
91+
>&2 echo Using ${PIP_BIN}...
92+
${PIP_BIN} install "${DIST_NAME}" --no-index -f ${WHEEL_DEP_DIR}
3893
done
3994

40-
chmod 0777 wheelhouse/*.whl
95+
chown -R 1000:1000 ${WHEELHOUSE_DIR}
96+
>&2 echo Final OS-specific wheels for ${DIST_NAME}:
97+
ls -l ${WHEELHOUSE_DIR}/*.whl

0 commit comments

Comments
 (0)