Skip to content

Commit

Permalink
Add test case for #257
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mayeut committed Nov 8, 2020
1 parent 42a1e56 commit c406720
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
56 changes: 56 additions & 0 deletions tests/integration/gepetto_example_adder/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# This shall be run on manylinux2014_x86_64 to create test data for gepetto_example_adder

# Stop at any error, show all commands
set -exuo pipefail

OUTPUT_DIR=$(dirname $0)

#mkdir /root/maketest
cd /root/maketest

# Install ninja
PY38_BIN=/opt/python/cp38-cp38/bin
$PY38_BIN/pip install ninja
ln -sf $PY38_BIN/ninja /usr/local/bin/
ln -sf $PY38_BIN/wheel /usr/local/bin/

# build boost
curl -fsSLO https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2
tar -xf boost_1_72_0.tar.bz2
pushd boost_1_72_0
./bootstrap.sh --prefix=/usr/local
sed -i 's/using python.*/python_config/g' project-config.jam
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
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
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
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
sed -i 's/python_config//g' project-config.jam

./b2 install link=shared python=3.6,3.7,3.8,3.9 --with-python --with-test -j"$(nproc)"
popd

# build example-adder
git clone --recursive https://github.com/Ozon2/example-adder.git
pushd example-adder
git checkout d319dae3849b9dc3161b2b6cbafa9e45204dcc14

for PYBIN in /opt/python/{cp36*,cp37*,cp38*,cp39*}/bin; do
rm -rf _skbuild/
"$PYBIN"/pip install --upgrade pip
"$PYBIN"/pip install scikit-build
"$PYBIN"/python setup.py bdist_wheel
done
popd

# strip/compress dependencies
for PYVER in 36 37 38 39; do
strip --strip-unneeded /usr/local/lib/libboost_python${PYVER}.so.1.72.0
xz -z -c -e /usr/local/lib/libboost_python${PYVER}.so.1.72.0 > ${OUTPUT_DIR}/libboost_python${PYVER}.so.1.72.0.xz
done
strip --strip-unneeded example-adder/_skbuild/linux-x86_64-3.9/cmake-build/libexample-adder.so.3.0.2-6-gd319
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

# copy wheels
cp example-adder/dist/* ${OUTPUT_DIR}/
58 changes: 58 additions & 0 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,3 +657,61 @@ def test_strip_wheel(any_manylinux_container, docker_python, io_folder):
["python", "-c", "from sample_extension import test_func; print(test_func(1))"]
)
assert output.strip() == "2"


def test_rpath(any_manylinux_container, docker_python, io_folder):
policy, manylinux_ctr = any_manylinux_container
if policy != 'manylinux2014_x86_64':
pytest.skip('This test can only run on manylinux2014_x86_64')
orig_wheel = f'gepetto_example_adder-3.0.2-{PYTHON_ABI}-linux_x86_64.whl'
# decompress dependencies
docker_exec(manylinux_ctr, [
'bash', '-c',
'xz -d -c /auditwheel_src/tests/integration/gepetto_example_adder/'
f'libboost_python{PYTHON_ABI_MAJ_MIN}.so.1.72.0.xz > '
f'/usr/local/lib/libboost_python{PYTHON_ABI_MAJ_MIN}.so.1.72.0'
])
docker_exec(manylinux_ctr, [
'bash', '-c',
'xz -d -c /auditwheel_src/tests/integration/gepetto_example_adder/'
'libexample-adder.so.3.0.2-6-gd319.xz > '
'/usr/local/lib/libexample-adder.so.3.0.2-6-gd319'
])

# check the original wheel is not compliant
output = docker_exec(manylinux_ctr, [
'auditwheel', 'show',
f'/auditwheel_src/tests/integration/gepetto_example_adder/{orig_wheel}'
])
assert (
f'{orig_wheel} is consistent with the following platform tag: '
f'"linux_{PLATFORM}"'
) in output.replace('\n', ' ')

# repair
docker_exec(manylinux_ctr, [
'auditwheel', '-v', 'repair', '-w', '/io',
f'/auditwheel_src/tests/integration/gepetto_example_adder/{orig_wheel}'
])
filenames = os.listdir(io_folder)
assert len(filenames) == 1
repaired_wheels = [fn for fn in filenames if policy in fn]
expected_wheel_name = \
f'gepetto_example_adder-3.0.2-{PYTHON_ABI}-{policy}.whl'
assert repaired_wheels == [expected_wheel_name]
repaired_wheel = repaired_wheels[0]
output = docker_exec(manylinux_ctr, [
'auditwheel', 'show', f'/io/{repaired_wheel}'
])
assert (
f'{expected_wheel_name} is consistent with the following platform tag: '
f'"{policy}"'
) in output.replace('\n', ' ')

docker_exec(docker_python, ['pip', 'install', f'/io/{repaired_wheel}'])
with pytest.raises(CalledProcessError):
docker_exec(docker_python, [
'python', '-c',
'import example_adder as exa; assert exa.add(4, 3) == 7'
])
pytest.xfail('Bad RPATH')

0 comments on commit c406720

Please sign in to comment.