Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for compiled cffi pypy extensions, fixes #93 #94

Merged
merged 3 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion auditwheel/elfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def elf_references_PyFPE_jbuf(elf: ELFFile) -> bool:

def elf_is_python_extension(fn, elf) -> Tuple[bool, Optional[int]]:
modname = basename(fn).split('.', 1)[0]
module_init_f = {'init' + modname: 2, 'PyInit_' + modname: 3}
module_init_f = {
'init' + modname: 2,
'PyInit_' + modname: 3,
'_cffi_pypyinit_' + modname: 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are 2 and 3 in this context? We might want to change these to named constants for legibility :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are versions of Python used to determine if extension may use ucs-2 functions. Corresponding code is in auditwheel.wheel_abi.get_wheel_elfdata. In case of CPython those numbers are really Python version but in case if pypy cffi python version cannot be derived from the name of module init function so I left 2 there.

}

sect = elf.get_section_by_name('.dynsym')
if sect is None:
Expand Down
3 changes: 2 additions & 1 deletion auditwheel/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def copylib(src_path, dest_dir):
with open(src_path, 'rb') as f:
shorthash = hashfile(f)[:8]

base, ext = os.path.basename(src_path).split('.', 1)
src_name = os.path.basename(src_path)
base, ext = src_name.split('.', 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, this is a 2-for-1 to fix #91. Got it.

if not base.endswith('-%s' % shorthash):
new_soname = '%s-%s.%s' % (base, shorthash, ext)
else:
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/test_bundled_pypy_snappy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from auditwheel.wheel_abi import analyze_wheel_abi


def test_analyze_wheel_abi_pypy_cffi():
winfo = analyze_wheel_abi(
'tests/python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl')
external_libs = winfo.external_refs['manylinux1_x86_64']['libs']
assert len(external_libs) > 0
assert set(external_libs) == {'libsnappy.so.1'}