matthew-brett / delocate

Find and copy needed dynamic libraries into python wheels
BSD 2-Clause "Simplified" License
266 stars 58 forks source link

DelocationError: libjpeg.9.dylib already exists #69

Closed harshithdwivedi closed 4 years ago

harshithdwivedi commented 4 years ago

Hi, While trying to build rawpy; delocate throws an error while it's copying the dylibs into the created whl.

Here's the complete error log: https://github.com/letmaik/rawpy/runs/502822701#step:4:1769

Any ideas as to what might be done to fix this?

letmaik commented 4 years ago

This may be the same as #53. To debug this, I would first extend https://github.com/matthew-brett/delocate/blob/master/delocate/cmd/delocate_listdeps.py to recursively dump dependencies, not just the first level. If libjpeg appears twice but with different paths then the build of rawpy must be fixed.

harshithdwivedi commented 4 years ago

@letmaik @matthew-brett is there a reason that the code snippet in delocating.py throws an exception if the file that's to be copied already exists?

if exists(out_path):
            raise DelocationError(out_path + ' already exists')

I mean, we are using shutil to copy the dylib files; so in case if the file exists, shutil will simply overwrite it; so what's the reason for raising an exception as opposed to simply logging it as a warning?

I replaced the exception with a print statement and the build succeeded without any issues whatsoever.

letmaik commented 4 years ago

This is to "catch" cases like #53 where you accidentally linked against two different versions (=paths) of the same library. You can simply override the file and hope for the best, but it's better to fix the root cause. Note that the lines above already check for the valid case where multiple libraries link against the same version/path of a dependency: https://github.com/matthew-brett/delocate/blob/28f13edaeebd818ea59f2f1b65cea49fea853f59/delocate/delocating.py#L224-L227

harshithdwivedi commented 4 years ago

Ah, alright. Makes sense.

harshithdwivedi commented 4 years ago

Fixed in https://github.com/letmaik/rawpy/commit/acc7683b2e66234dfeab1eecaba94f97bfa165d0