Skip to content

Commit c406720

Browse files
committed
Add test case for #257
It would be better to rebuild the sample from source to get it for all images but it's a bit complex to rebuild in a generic way.
1 parent 42a1e56 commit c406720

11 files changed

+114
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# This shall be run on manylinux2014_x86_64 to create test data for gepetto_example_adder
4+
5+
# Stop at any error, show all commands
6+
set -exuo pipefail
7+
8+
OUTPUT_DIR=$(dirname $0)
9+
10+
#mkdir /root/maketest
11+
cd /root/maketest
12+
13+
# Install ninja
14+
PY38_BIN=/opt/python/cp38-cp38/bin
15+
$PY38_BIN/pip install ninja
16+
ln -sf $PY38_BIN/ninja /usr/local/bin/
17+
ln -sf $PY38_BIN/wheel /usr/local/bin/
18+
19+
# build boost
20+
curl -fsSLO https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2
21+
tar -xf boost_1_72_0.tar.bz2
22+
pushd boost_1_72_0
23+
./bootstrap.sh --prefix=/usr/local
24+
sed -i 's/using python.*/python_config/g' project-config.jam
25+
sed -i 's&python_config&python_config\n using python : 3.9 : /opt/python/cp39-cp39/bin/python : /opt/python/cp39-cp39/include/python3.9 : /opt/python/cp39-cp39/lib ;&g' project-config.jam
26+
sed -i 's&python_config&python_config\n using python : 3.8 : /opt/python/cp38-cp38/bin/python : /opt/python/cp38-cp38/include/python3.8 : /opt/python/cp38-cp38/lib ;&g' project-config.jam
27+
sed -i 's&python_config&python_config\n using python : 3.7 : /opt/python/cp37-cp37m/bin/python : /opt/python/cp37-cp37m/include/python3.7m : /opt/python/cp37-cp37m/lib ;&g' project-config.jam
28+
sed -i 's&python_config&python_config\n using python : 3.6 : /opt/python/cp36-cp36m/bin/python : /opt/python/cp36-cp36m/include/python3.6m : /opt/python/cp36-cp36m/lib ;&g' project-config.jam
29+
sed -i 's/python_config//g' project-config.jam
30+
31+
./b2 install link=shared python=3.6,3.7,3.8,3.9 --with-python --with-test -j"$(nproc)"
32+
popd
33+
34+
# build example-adder
35+
git clone --recursive https://github.com/Ozon2/example-adder.git
36+
pushd example-adder
37+
git checkout d319dae3849b9dc3161b2b6cbafa9e45204dcc14
38+
39+
for PYBIN in /opt/python/{cp36*,cp37*,cp38*,cp39*}/bin; do
40+
rm -rf _skbuild/
41+
"$PYBIN"/pip install --upgrade pip
42+
"$PYBIN"/pip install scikit-build
43+
"$PYBIN"/python setup.py bdist_wheel
44+
done
45+
popd
46+
47+
# strip/compress dependencies
48+
for PYVER in 36 37 38 39; do
49+
strip --strip-unneeded /usr/local/lib/libboost_python${PYVER}.so.1.72.0
50+
xz -z -c -e /usr/local/lib/libboost_python${PYVER}.so.1.72.0 > ${OUTPUT_DIR}/libboost_python${PYVER}.so.1.72.0.xz
51+
done
52+
strip --strip-unneeded example-adder/_skbuild/linux-x86_64-3.9/cmake-build/libexample-adder.so.3.0.2-6-gd319
53+
xz -z -c -e example-adder/_skbuild/linux-x86_64-3.9/cmake-build/libexample-adder.so.3.0.2-6-gd319 > ${OUTPUT_DIR}/libexample-adder.so.3.0.2-6-gd319.xz
54+
55+
# copy wheels
56+
cp example-adder/dist/* ${OUTPUT_DIR}/

tests/integration/test_manylinux.py

+58
Original file line numberDiff line numberDiff line change
@@ -657,3 +657,61 @@ def test_strip_wheel(any_manylinux_container, docker_python, io_folder):
657657
["python", "-c", "from sample_extension import test_func; print(test_func(1))"]
658658
)
659659
assert output.strip() == "2"
660+
661+
662+
def test_rpath(any_manylinux_container, docker_python, io_folder):
663+
policy, manylinux_ctr = any_manylinux_container
664+
if policy != 'manylinux2014_x86_64':
665+
pytest.skip('This test can only run on manylinux2014_x86_64')
666+
orig_wheel = f'gepetto_example_adder-3.0.2-{PYTHON_ABI}-linux_x86_64.whl'
667+
# decompress dependencies
668+
docker_exec(manylinux_ctr, [
669+
'bash', '-c',
670+
'xz -d -c /auditwheel_src/tests/integration/gepetto_example_adder/'
671+
f'libboost_python{PYTHON_ABI_MAJ_MIN}.so.1.72.0.xz > '
672+
f'/usr/local/lib/libboost_python{PYTHON_ABI_MAJ_MIN}.so.1.72.0'
673+
])
674+
docker_exec(manylinux_ctr, [
675+
'bash', '-c',
676+
'xz -d -c /auditwheel_src/tests/integration/gepetto_example_adder/'
677+
'libexample-adder.so.3.0.2-6-gd319.xz > '
678+
'/usr/local/lib/libexample-adder.so.3.0.2-6-gd319'
679+
])
680+
681+
# check the original wheel is not compliant
682+
output = docker_exec(manylinux_ctr, [
683+
'auditwheel', 'show',
684+
f'/auditwheel_src/tests/integration/gepetto_example_adder/{orig_wheel}'
685+
])
686+
assert (
687+
f'{orig_wheel} is consistent with the following platform tag: '
688+
f'"linux_{PLATFORM}"'
689+
) in output.replace('\n', ' ')
690+
691+
# repair
692+
docker_exec(manylinux_ctr, [
693+
'auditwheel', '-v', 'repair', '-w', '/io',
694+
f'/auditwheel_src/tests/integration/gepetto_example_adder/{orig_wheel}'
695+
])
696+
filenames = os.listdir(io_folder)
697+
assert len(filenames) == 1
698+
repaired_wheels = [fn for fn in filenames if policy in fn]
699+
expected_wheel_name = \
700+
f'gepetto_example_adder-3.0.2-{PYTHON_ABI}-{policy}.whl'
701+
assert repaired_wheels == [expected_wheel_name]
702+
repaired_wheel = repaired_wheels[0]
703+
output = docker_exec(manylinux_ctr, [
704+
'auditwheel', 'show', f'/io/{repaired_wheel}'
705+
])
706+
assert (
707+
f'{expected_wheel_name} is consistent with the following platform tag: '
708+
f'"{policy}"'
709+
) in output.replace('\n', ' ')
710+
711+
docker_exec(docker_python, ['pip', 'install', f'/io/{repaired_wheel}'])
712+
with pytest.raises(CalledProcessError):
713+
docker_exec(docker_python, [
714+
'python', '-c',
715+
'import example_adder as exa; assert exa.add(4, 3) == 7'
716+
])
717+
pytest.xfail('Bad RPATH')

0 commit comments

Comments
 (0)