Skip to content

Commit 8a21057

Browse files
committed
travis: add openssl for manylinux builds
1 parent 2c9c2e5 commit 8a21057

File tree

5 files changed

+242
-24
lines changed

5 files changed

+242
-24
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ matrix:
1111
- os: linux
1212
dist: trusty
1313
sudo: required
14-
env: CIBW_BEFORE_BUILD="tools/bootstrap-librdkafka.sh master /usr"
14+
env: CIBW_BEFORE_BUILD="tools/prepare-cibuildwheel-linux.sh"
1515
language: python
1616
python: "2.7"
1717
services: docker

tools/build-manylinux.sh

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
# Usage in container:
1515
# docker run -t -v $(pwd):/io quay.io/pypa/manylinux1_x86_64:latest /io/tools/build-manylinux.sh <librdkafka_tag>
1616

17-
# NOTE: Keep this updated to make sure we always build the latest
18-
# version of OpenSSL in the 1.0 release train.
19-
OPENSSL_VERSION=1.0.2l
20-
2117
LIBRDKAFKA_VERSION=$1
2218

2319
if [[ -z "$LIBRDKAFKA_VERSION" ]]; then
@@ -47,30 +43,14 @@ fi
4743
# Running in container
4844
#
4945

50-
function install_openssl {
51-
rm -rf build-openssl
52-
mkdir -p build-openssl
53-
pushd build-openssl
54-
curl -s -l https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | \
55-
tar -xz --strip-components=1 -f -
56-
./config --prefix=/usr/local zlib no-krb5 zlib shared
57-
echo "## building openssl"
58-
make 2>&1 | tail -50
59-
echo "## testing openssl"
60-
make test 2>&1 | tail -50
61-
echo "## installing openssl"
62-
make install 2>&1 | tail -50
63-
popd
64-
}
65-
6646
echo "# Installing basic system dependencies"
6747
yum install -y zlib-devel gcc-c++
6848

69-
echo "# Building OpenSSL ${OPENSSL_VERSION}"
70-
install_openssl
49+
# Build OpenSSL
50+
$(dirname $0)/build-openssl.sh /usr
7151

7252
echo "# Building librdkafka ${LIBRDKAFKA_VERSION}"
73-
$(dirname $0)/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} /usr/local
53+
$(dirname $0)/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} /usr
7454

7555
# Compile wheels
7656
echo "# Compile"

tools/build-openssl.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
4+
# Builds and installs OpenSSL for later use by build-manylinux.sh,
5+
# bootstrap-librdkafka.sh, etc.
6+
7+
# NOTE: Keep this updated to make sure we always build the latest
8+
# version of OpenSSL in the 1.0 release train.
9+
OPENSSL_VERSION=1.0.2l
10+
11+
PREFIX=$1
12+
if [[ -z $PREFIX ]]; then
13+
echo "Usage: $0 <installation-prefix>"
14+
fi
15+
16+
set -ex
17+
18+
echo "# Building OpenSSL ${OPENSSL_VERSION}"
19+
20+
rm -rf build-openssl
21+
mkdir -p build-openssl
22+
pushd build-openssl
23+
curl -s -l https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | \
24+
tar -xz --strip-components=1 -f -
25+
./config --prefix=${PREFIX} zlib no-krb5 zlib shared
26+
echo "## building openssl"
27+
make 2>&1 | tail -50
28+
echo "## testing openssl"
29+
make test 2>&1 | tail -50
30+
echo "## installing openssl"
31+
make install 2>&1 | tail -50
32+
popd
33+
34+
35+

tools/download-s3.py

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
#!/usr/bin/env python
2+
#
3+
#
4+
# Collects CI artifacts from S3 storage, downloading them
5+
# to a local directory.
6+
#
7+
# The artifacts' folder in the S3 bucket must have the following token
8+
# format:
9+
# <token>-[<value>]__ (repeat)
10+
#
11+
# Recognized tokens (unrecognized tokens are ignored):
12+
# p - project (e.g., "confluent-kafka-python")
13+
# bld - builder (e.g., "travis")
14+
# plat - platform ("osx", "linux", ..)
15+
# tag - git tag
16+
# sha - git sha
17+
# bid - builder's build-id
18+
#
19+
# Example:
20+
# p-confluent-kafka-python__bld-travis__plat-linux__tag-__sha-112130ce297656ea1c39e7c94c99286f95133a24__bid-271588764__/confluent_kafka-0.11.0-cp35-cp35m-manylinux1_x86_64.whl
21+
22+
23+
import sys
24+
import re
25+
import os
26+
import argparse
27+
28+
import boto3
29+
30+
s3_bucket = 'librdkafka-ci-packages'
31+
dry_run = False
32+
33+
34+
35+
class Artifact (object):
36+
def __init__ (self, arts, path, info=None):
37+
self.path = path
38+
# Remove unexpanded AppVeyor $(..) tokens from filename
39+
self.fname = re.sub(r'\$\([^\)]+\)', '', os.path.basename(path))
40+
self.lpath = os.path.join(arts.dlpath, self.fname)
41+
self.info = info
42+
self.arts = arts
43+
arts.artifacts.append(self)
44+
45+
def __repr__ (self):
46+
return self.path
47+
48+
def download (self, dirpath):
49+
""" Download artifact from S3 and store in dirpath directory.
50+
If the artifact is already downloaded nothing is done. """
51+
dest = self.lpath
52+
if os.path.isfile(self.lpath) and os.path.getsize(self.lpath) > 0:
53+
return
54+
print('Downloading %s -> %s' % (self.path, self.lpath))
55+
if dry_run:
56+
return
57+
self.arts.s3_bucket.download_file(self.path, self.lpath)
58+
59+
60+
class Artifacts (object):
61+
def __init__ (self, gitref, dlpath):
62+
super(Artifacts, self).__init__()
63+
self.gitref = gitref
64+
self.artifacts = list()
65+
# Download directory
66+
self.dlpath = dlpath
67+
if not os.path.isdir(self.dlpath):
68+
if not dry_run:
69+
os.makedirs(self.dlpath, 0755)
70+
71+
def collect_single (self, path, folder):
72+
""" Collect single entry
73+
:param: path string: S3 or local path to file
74+
:param: folder string: S3 folder name
75+
"""
76+
folder = os.path.dirname(key.key)
77+
78+
rinfo = re.findall(r'(?P<tag>[^-]+)-(?P<val>.*?)__', folder)
79+
if rinfo is None or len(rinfo) == 0:
80+
# print('Incorrect folder/file name format for %s' % folder)
81+
return None
82+
83+
info = dict(rinfo)
84+
85+
# Ignore AppVeyor Debug builds
86+
if info.get('bldtype', '').lower() == 'debug':
87+
print('Ignoring debug artifact %s' % folder)
88+
return None
89+
90+
tag = info.get('tag', None)
91+
if tag is not None and (len(tag) == 0 or tag.startswith('$(')):
92+
# AppVeyor doesn't substite $(APPVEYOR_REPO_TAG_NAME)
93+
# with an empty value when not set, it leaves that token
94+
# in the string - so translate that to no tag.
95+
tag = None
96+
97+
sha = info.get('sha', None)
98+
if (tag is not None and tag == self.gitref) or (sha is not None and sha.startswith(self.gitref)):
99+
return Artifact(self, path, info, lpath=lpath)
100+
101+
return None
102+
103+
def collect_single_s3 (self, path):
104+
""" Collect single S3 artifact
105+
:param: path string: S3 path
106+
"""
107+
108+
# The S3 folder contains the tokens needed to perform
109+
# matching of project, gitref, etc.
110+
folder = os.path.dirname(path)
111+
112+
rinfo = re.findall(r'(?P<tag>[^-]+)-(?P<val>.*?)__', folder)
113+
if rinfo is None or len(rinfo) == 0:
114+
# print('Incorrect folder/file name format for %s' % folder)
115+
return None
116+
117+
info = dict(rinfo)
118+
119+
# Ignore AppVeyor Debug builds
120+
if info.get('bldtype', '').lower() == 'debug':
121+
print('Ignoring debug artifact %s' % folder)
122+
return None
123+
124+
tag = info.get('tag', None)
125+
if tag is not None and (len(tag) == 0 or tag.startswith('$(')):
126+
# AppVeyor doesn't substite $(APPVEYOR_REPO_TAG_NAME)
127+
# with an empty value when not set, it leaves that token
128+
# in the string - so translate that to no tag.
129+
tag = None
130+
131+
sha = info.get('sha', None)
132+
133+
# Match tag or sha to gitref
134+
if (tag is not None and tag == self.gitref) or (sha is not None and sha.startswith(self.gitref)):
135+
return Artifact(self, path, info)
136+
137+
return None
138+
139+
140+
def collect_s3 (self):
141+
""" Collect and download build-artifacts from S3 based on git reference """
142+
print('Collecting artifacts matching tag/sha %s from S3 bucket %s' % (self.gitref, s3_bucket))
143+
self.s3 = boto3.resource('s3')
144+
self.s3_bucket = self.s3.Bucket(s3_bucket)
145+
self.s3.meta.client.head_bucket(Bucket=s3_bucket)
146+
for key in self.s3_bucket.objects.all():
147+
self.collect_single_s3(key.key)
148+
149+
for a in self.artifacts:
150+
a.download(self.dlpath)
151+
152+
def collect_local (self, path):
153+
""" Collect artifacts from a local directory possibly previously
154+
collected from s3 """
155+
for f in os.listdir(path):
156+
lpath = os.path.join(path, f)
157+
if not os.path.isfile(lpath):
158+
continue
159+
Artifact(self, lpath)
160+
161+
162+
163+
if __name__ == '__main__':
164+
165+
parser = argparse.ArgumentParser()
166+
parser.add_argument("--no-s3", help="Don't collect from S3", action="store_true")
167+
parser.add_argument("--dry-run", help="Locate artifacts but don't actually download or do anything", action="store_true")
168+
parser.add_argument("--directory", help="Download directory (default: dl-<gitref>)", default=None)
169+
parser.add_argument("tag", help="Tag or git SHA to collect")
170+
171+
args = parser.parse_args()
172+
dry_run = args.dry_run
173+
gitref = args.tag
174+
if not args.directory:
175+
args.directory = 'dl-%s' % gitref
176+
177+
arts = Artifacts(gitref, args.directory)
178+
179+
if not args.no_s3:
180+
arts.collect_s3()
181+
else:
182+
arts.collect_local(arts.dlpath)
183+
184+
if len(arts.artifacts) == 0:
185+
raise ValueError('No artifacts found for %s' % arts.gitref)
186+
187+
print('Collected artifacts:')
188+
for a in arts.artifacts:
189+
print(' %s -> %s' % (a.path, a.lpath))

tools/prepare-cibuildwheel-linux.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
#
3+
4+
# cibuildwheel builder for Linux
5+
6+
echo "# Installing basic system dependencies"
7+
yum install -y zlib-devel gcc-c++
8+
9+
# Build OpenSSL
10+
$(dirname $0)/build-openssl.sh /usr
11+
12+
echo "# Building librdkafka ${LIBRDKAFKA_VERSION}"
13+
$(dirname $0)/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} /usr
14+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy