Skip to content

Commit

Permalink
Modify rpath wheel to add a recursive dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
HexDecimal committed Jul 11, 2021
1 parent ce80174 commit c11c62d
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 11 deletions.
Binary file not shown.
Binary file modified delocate/tests/data/fakepkg2-1.0-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file added delocate/tests/data/libextfunc2_rpath.dylib
Binary file not shown.
Binary file modified delocate/tests/data/libextfunc_rpath.dylib
Binary file not shown.
2 changes: 1 addition & 1 deletion delocate/tests/data/wheel_build_path.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/Users/brettmz-admin/dev_trees/delocate/wheel_makers
/Users/runner/work/delocate/delocate/wheel_makers
9 changes: 7 additions & 2 deletions delocate/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ def _proc_lines(in_str):

def test_listdeps():
# smokey tests of list dependencies command
local_libs = set(['liba.dylib', 'libb.dylib', 'libc.dylib'])
local_libs = {
'liba.dylib',
'libb.dylib',
'libc.dylib',
'libextfunc2_rpath.dylib',
}
# single path, with libs
code, stdout, stderr = run_command(['delocate-listdeps', DATA_PATH])
assert_equal(set(stdout), local_libs)
assert set(stdout) == local_libs
assert_equal(code, 0)
# single path, no libs
with InTemporaryDirectory():
Expand Down
16 changes: 11 additions & 5 deletions delocate/tests/test_wheelies.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,23 @@ def test_fix_rpath():
# The module was set to expect its dependency in the libs/ directory
os.symlink(DATA_PATH, 'libs')

stray_lib = realpath('libs/libextfunc_rpath.dylib')
with InWheel(RPATH_WHEEL):
# dep_mod can vary depending the Python version used to build
# the test wheel
dep_mod = 'fakepkg/subpkg/module2.abi3.so'
dep_path = '@rpath/libextfunc_rpath.dylib'

assert_equal(
delocate_wheel(RPATH_WHEEL, 'tmp.whl'),
{stray_lib: {dep_mod: dep_path}},
)
stray_libs = {
realpath('libs/libextfunc_rpath.dylib'): {dep_mod: dep_path},
realpath('libs/libextfunc2_rpath.dylib'): {
realpath(
'libs/libextfunc_rpath.dylib'
): '@rpath/libextfunc2_rpath.dylib'
},
}

assert delocate_wheel(RPATH_WHEEL, 'tmp.whl') == stray_libs

with InWheel('tmp.whl'):
check_call(['codesign', '--verify',
'fakepkg/.dylibs/libextfunc_rpath.dylib'])
4 changes: 3 additions & 1 deletion wheel_makers/fakepkg_rpath/libs/extfunc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
int extfunc2();

int extfunc()
{
return 3;
return extfunc2();
}
4 changes: 4 additions & 0 deletions wheel_makers/fakepkg_rpath/libs/extfunc2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int extfunc2()
{
return 3;
}
20 changes: 18 additions & 2 deletions wheel_makers/fakepkg_rpath/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,33 @@

HERE = abspath(dirname(__file__))
LIBS = pjoin(HERE, 'libs')
EXTLIB = pjoin(LIBS, 'libextfunc_rpath.dylib')
INSTALL_NAME = '@rpath/libextfunc_rpath.dylib'

arch_flags = ['-arch', 'arm64', '-arch', 'x86_64'] # dual arch

EXTLIB2 = pjoin(LIBS, 'libextfunc2_rpath.dylib')
INSTALL_NAME2 = '@rpath/libextfunc2_rpath.dylib'
check_call([
'cc', pjoin(LIBS, 'extfunc2.c'),
'-dynamiclib',
'-install_name', INSTALL_NAME2,
'-o', EXTLIB2,
] + arch_flags)

EXTLIB = pjoin(LIBS, 'libextfunc_rpath.dylib')
INSTALL_NAME = '@rpath/libextfunc_rpath.dylib'
check_call([
'cc', pjoin(LIBS, 'extfunc.c'),
'-dynamiclib',
'-install_name', INSTALL_NAME,
'-L', LIBS,
'-l', 'extfunc2_rpath',
'-rpath', "@executable_path/",
'-rpath', "@loader_path/",
'-o', EXTLIB,
] + arch_flags)

check_call(['codesign', '--sign', '-', EXTLIB])
check_call(['codesign', '--sign', '-', EXTLIB2])

exts = [
Extension(
Expand Down

0 comments on commit c11c62d

Please sign in to comment.