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

Feature request: add option to disable name mangling selectively #380

Open
duburcqa opened this issue May 12, 2022 · 0 comments
Open

Feature request: add option to disable name mangling selectively #380

duburcqa opened this issue May 12, 2022 · 0 comments

Comments

@duburcqa
Copy link

Shipping dependencies is essential for portability. Hashing the name is also a good practice to avoid collisions when loading several modules relying on different versions of the same library. Still, in some cases it is strictly necessary to be able to load a library dependency only once and share it between modules. For instance, it is how the interoperability of boost::python works under the hood. So far, I made a custom patch that I'm using in production since more than a year without issue:

copylib_orig = auditwheel.repair.copylib

def copylib(src_path: str, dest_dir: str,
            patcher: ElfPatcher) -> Tuple[str, str]:
    # Do NOT hash filename to make it unique in the particular case of boost
    # python modules, since otherwise it will be impossible to share a common
    # registry, which is necessary for cross module interoperability.
    if "libboost_python" in src_path:
        src_name = os.path.basename(src_path)
        dest_path = os.path.join(dest_dir, src_name)
        if os.path.exists(dest_path):
            return src_name, dest_path

        logger.debug('Grafting: %s -> %s', src_path, dest_path)
        shutil.copy2(src_path, dest_path)
        rpaths = elf_read_rpaths(src_path)
        statinfo = os.stat(dest_path)
        if not statinfo.st_mode & stat.S_IWRITE:
            os.chmod(dest_path, statinfo.st_mode | stat.S_IWRITE)
        patcher.set_soname(dest_path, src_name)
        if any(itertools.chain(rpaths['rpaths'], rpaths['runpaths'])):
            patcher.set_rpath(dest_path, dest_dir)

        return src_name, dest_path
    return copylib_orig(src_path, dest_dir, patcher)

auditwheel.repair.copylib = copylib

May be it would be beneficial to other users facing a similar issue to add this option in auditwheel itself. I can understand that it is going against the very principle of auditwheel to some extent since it may break packages that are relying on incompatible versions, but it is absolutely necessary in some cases. Besides, boost::python is extremely stable and not really making any progress since years, so I think it is quite safe at least for this particular case.

@duburcqa duburcqa changed the title Feature request: add option to disable hashing the libary name of the dependencies Feature request: add option to disable name mangling for some dependencies May 12, 2022
@duburcqa duburcqa changed the title Feature request: add option to disable name mangling for some dependencies Feature request: add option to disable name mangling selectively May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant