Skip to content

Commit cc79c8a

Browse files
committed
update test case to test comma sepparated list
1 parent f66f257 commit cc79c8a

File tree

6 files changed

+52
-31
lines changed

6 files changed

+52
-31
lines changed

tests/integration/test_manylinux.py

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,27 +329,44 @@ def test_repair_exclude(self, any_manylinux_container, io_folder):
329329
orig_wheel = filenames[0]
330330
assert "manylinux" not in orig_wheel
331331

332-
repair_command = [
333-
f"LD_LIBRARY_PATH={test_path}/a:$LD_LIBRARY_PATH",
334-
"auditwheel",
335-
"repair",
336-
f"--plat={policy}",
337-
"--only-plat",
338-
"-w",
339-
"/io",
340-
"--exclude=liba.so",
341-
f"/io/{orig_wheel}",
342-
]
343-
output = docker_exec(manylinux_ctr, ["bash", "-c", " ".join(repair_command)])
344-
assert "Excluding liba.so" in output
345-
filenames = os.listdir(io_folder)
346-
assert len(filenames) == 2
347-
repaired_wheel = f"testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl"
348-
assert repaired_wheel in filenames
349-
350-
# Make sure we don't have liba.so & libb.so in the result
351-
contents = zipfile.ZipFile(os.path.join(io_folder, repaired_wheel)).namelist()
352-
assert not any(x for x in contents if "/liba" in x or "/libb" in x)
332+
def run_repair_test(exclude_args, expected_exclusions):
333+
repair_command = [
334+
f"LD_LIBRARY_PATH={test_path}/a:$LD_LIBRARY_PATH",
335+
"auditwheel",
336+
"repair",
337+
f"--plat={policy}",
338+
"--only-plat",
339+
"-w",
340+
"/io",
341+
] + exclude_args + [
342+
f"/io/{orig_wheel}",
343+
]
344+
output = docker_exec(manylinux_ctr, ["bash", "-c", " ".join(repair_command)])
345+
346+
# Check for exclusions in the output
347+
for arg in exclude_args:
348+
if ',' in arg:
349+
libs = arg.split('=')[1].split(',')
350+
for lib in libs:
351+
assert f"Excluding {lib}" in output
352+
else:
353+
lib = arg.split('=')[1]
354+
assert f"Excluding {lib}" in output
355+
356+
filenames = os.listdir(io_folder)
357+
assert len(filenames) == 2
358+
repaired_wheel = f"testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl"
359+
assert repaired_wheel in filenames
360+
361+
# Make sure we don't have the excluded libraries in the result
362+
contents = zipfile.ZipFile(os.path.join(io_folder, repaired_wheel)).namelist()
363+
for lib in expected_exclusions:
364+
assert not any(x for x in contents if f"/{lib}" in x)
365+
366+
# Test case 1: Exclude liba.so only - it will exclude libb.so as well due to indirect reference
367+
run_repair_test(["--exclude=liba.so", "--exclude=libx.so"], ["liba.so", "libb.so", "libx.so"])
368+
# Test case 2: Exclude liba.so and libx.so using comma separated
369+
run_repair_test(["--exclude=liba.so,libx.so"], ["liba.so", "libb.so", "libx.so"])
353370

354371
def test_build_wheel_with_binary_executable(
355372
self, any_manylinux_container, docker_python, io_folder

tests/integration/testrpath/c/c.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/integration/testrpath/setup.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def run(self) -> None:
1212
cmd = "gcc -fPIC -shared -o b/libb.so b/b.c"
1313
subprocess.check_call(cmd.split())
1414

15-
cmd = "gcc -fPIC -shared -o c/libc.so c/c.c"
15+
cmd = "gcc -fPIC -shared -o x/libx.so x/x.c"
1616
subprocess.check_call(cmd.split())
1717

1818
cmd = (
1919
"gcc -fPIC -shared -o a/liba.so "
20-
"-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b -Wl,-rpath=$ORIGIN/../c "
21-
"-Ib a/a.c -Lb -Lc -lb -lc"
20+
"-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b "
21+
"-Ib a/a.c -Lb -lb"
2222
).format(
2323
dtags_flag=(
2424
"--enable-new-dtags"
@@ -40,9 +40,13 @@ def run(self) -> None:
4040
Extension(
4141
"testrpath/testrpath",
4242
sources=["src/testrpath/testrpath.c"],
43-
include_dirs=["a", "c"],
44-
libraries=["a", "c"],
45-
library_dirs=["a", "c"],
43+
include_dirs=["a", "x"],
44+
libraries=["a", "x"],
45+
library_dirs=["a", "x"],
46+
extra_link_args=[
47+
'-Wl,-rpath,$ORIGIN/../a',
48+
'-Wl,-rpath,$ORIGIN/../x'
49+
],
4650
)
4751
],
4852
)

tests/integration/testrpath/src/testrpath/testrpath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <Python.h>
22
#include "a.h"
3-
#include "c.h"
3+
#include "x.h"
44

55
static PyObject *
66
func(PyObject *self, PyObject *args)
@@ -10,7 +10,7 @@ func(PyObject *self, PyObject *args)
1010
(void)self;
1111
(void)args;
1212

13-
res = fa() + fc();
13+
res = fa() + fx();
1414
return PyLong_FromLong(res);
1515
}
1616

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
int fc(void) {
1+
int fx(void) {
22
return 20;
33
}

tests/integration/testrpath/x/x.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int fx(void);

0 commit comments

Comments
 (0)