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

Add documentation how to use repairwheel with 'pip install .' #42

Open
PiotrCzapla opened this issue Oct 17, 2024 · 0 comments
Open

Add documentation how to use repairwheel with 'pip install .' #42

PiotrCzapla opened this issue Oct 17, 2024 · 0 comments

Comments

@PiotrCzapla
Copy link

PiotrCzapla commented Oct 17, 2024

Hello, I appreciate your efforts in creating this tool. I'm trying to resolve a broken building system in one of the open-source libraries, and I found it quite challenging to discover the proper approach. After spending hours searching and consulting ChatGPT, I eventually found a solution that works, but I'm still uncertain if it's the right method. Given the limited information available on how to correctly build a wheel with shared libraries, could you consider adding a few paragraphs to your README file?

While it's relatively easy to locate your library, when searching for issues related to rpath, getting the information how to make pip install . to call your tool is quite difficult. My current approach is as follows.

from pathlib import Path
from setuptools import setup, Command
from setuptools.command.bdist_wheel import bdist_wheel
import subprocess

class RepairWheel(bdist_wheel):
    def run(self):
         super().run()

         wheel_path = next(Path(self.dist_dir).glob(f"{self.distribution.get_name()}*.whl"))
         # Create a temporary directory for the repaired wheel
         import tempfile
         with tempfile.TemporaryDirectory(prefix='repaired_wheel_') as tmp_dir:
             tmp_dir = Path(tmp_dir)
             subprocess.call(['repairwheel', wheel_path, '-o', tmp_dir])

             # We need to glob as repairwheel may change the name of the wheel 
             # on linux from pywhispercpp-1.2.0-cp312-cp312-linux_aarch64.whl 
             #            to pywhispercpp-1.2.0-cp312-cp312-manylinux_2_34_aarch64.whl
             repaired_wheel = next(tmp_dir.glob("*.whl"))
             self.copy_file(repaired_wheel, wheel_path)
             print(f"Copied repaired wheel to: {wheel_path}")
     
setup(
        # ...
        cmdclass={
             'bdist_wheel': RepairWheel,
        },
        # ...
)

Actually afer some inspection I'm pretty sure that it isn't working well as I have copies of my .dylib in two places (in wheel/ and wheel/package/.dylibs/) but at least they reference each other.
If I find a way to fix this I will update the ticket.

@PiotrCzapla PiotrCzapla changed the title Add a bit docs how to use this tool with setuptools / pip install Add documentation how to use repairwheel with 'pip install .' Oct 17, 2024
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