Skip to main content
https://travis-ci.org/matthew-brett/delocate.svg?branch=master

Delocate

OSX utilities to:

  • find dynamic libraries imported from python extensions

  • copy needed dynamic libraries to directory within package

  • update OSX install_names and rpath to cause code to load from copies of libraries

Provides scripts:

  • delocate-listdeps – show libraries a tree depends on

  • delocate-path – copy libraries a tree depends on into the tree and relink

  • delocate-wheel – rewrite wheel having copied and relinked library dependencies into the wheel tree.

The problem

Let’s say you have built a wheel somewhere, but it’s linking to dynamic libraries elsewhere on the machine, so you can’t distribute it, because others may not have these same libraries. Here we analyze the dependencies for a scipy wheel:

$ delocate-listdeps scipy-0.14.0b1-cp34-cp34m-macosx_10_6_intel.whl
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgcc_s.1.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.3.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libquadmath.0.dylib

By default, this does not include libraries in /usr/lib and /System. See those too with:

$ delocate-listdeps --all scipy-0.14.0b1-cp34-cp34m-macosx_10_6_intel.whl
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
/usr/lib/libSystem.B.dylib
/usr/lib/libstdc++.6.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgcc_s.1.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.3.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libquadmath.0.dylib

The output tells me that scipy has picked up dynamic libraries from my homebrew installation of gfortran (as well as the system libs).

You can get a listing of the files depending on each of the libraries, using the --depending flag:

$ delocate-listdeps --depending scipy-0.14.0b1-cp34-cp34m-macosx_10_6_intel.whl
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgcc_s.1.dylib:
    scipy/interpolate/dfitpack.so
    scipy/special/specfun.so
    scipy/interpolate/_fitpack.so
    ...

A solution

We can fix like this:

$ delocate-wheel -w fixed_wheels -v scipy-0.14.0b1-cp34-cp34m-macosx_10_6_intel.whl
Fixing: scipy-0.14.0b1-cp34-cp34m-macosx_10_6_intel.whl
Copied to package .dylibs directory:
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgcc_s.1.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.3.dylib
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libquadmath.0.dylib

The -w flag tells delocate-wheel to output to a new wheel directory instead of overwriting the old wheel. -v (verbose) tells you what delocate-wheel is doing. In this case it has made a new directory in the wheel zipfile, named scipy/.dylibs. It has copied all the library dependencies that are outside the OSX system trees into this directory, and patched the python .so extensions in the wheel to use these copies instead of looking in /usr/local/Cellar/gfortran/4.8.2/gfortran/lib.

Check the links again to confirm:

$ delocate-listdeps fixed_wheels/scipy-0.14.0b1-cp34-cp34m-macosx_10_6_intel.whl
@loader_path/libgcc_s.1.dylib
@loader_path/libquadmath.0.dylib
@rpath/libgcc_s.1.dylib
@rpath/libgfortran.3.dylib
@rpath/libquadmath.0.dylib

So - system dylibs the same, but the others moved into the wheel tree.

This makes the wheel more likely to work on another machine which does not have the same version of gfortran installed - in this example.

Code

See https://github.com/matthew-brett/delocate

Released under the BSD two-clause license - see the file LICENSE in the source distribution.

travis-ci kindly tests the code automatically under Python 2.7, 3.3 and 3.4.

The latest released version is at https://pypi.python.org/pypi/delocate

Support

Please put up issues on the delocate issue tracker.

Metadata

Release files for delocate 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for delocate 0.4.0
File Size Uploaded
delocate-0.4.0.zip 72.3 kB Details
delocate-0.4.0.tar.gz 55.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for delocate 0.4.0
File Interpreter ABI Platform
delocate-0.4.0-py34-none-any.whl Python 3.4 none any Details
delocate-0.4.0-py33-none-any.whl Python 3.3 none any Details
delocate-0.4.0-py2-none-any.whl Python 2 none any Details

Total release size: 316.1 kB

Release files / delocate-0.4.0.zip

Download URL delocate-0.4.0.zip
Size 72.3 kB
Tags Source
SHA-256 checksum
How to use checksums
51f3963f192122275721082d6022ea8a7e5c6138f40311af5e7c3cef3fb1be5a
BLAKE2b-256 checksum
How to use checksums
93fdb9e05e7f337232d53f75919eb2a36e6e997ec7f7a4fe10c870c3fdeb2766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / delocate-0.4.0.tar.gz

Download URL delocate-0.4.0.tar.gz
Size 55.0 kB
Tags Source
SHA-256 checksum
How to use checksums
56bb91e443fffaa13bf9e5597cdacf0bff04a6c70ac5d8e9198712080ecb5f83
BLAKE2b-256 checksum
How to use checksums
0afa341f8bc2070f400f6c09ad9b58c500e173d34565c80b84d497dec81a2c59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / delocate-0.4.0-py34-none-any.whl

Download URL delocate-0.4.0-py34-none-any.whl
Size 62.9 kB
Tags Python 3.4
SHA-256 checksum
How to use checksums
59c2a92bd394b5f60dfcf644bde1387f78221fa8cb7b6c1897aa6e83ef41298b
BLAKE2b-256 checksum
How to use checksums
a6fa50022b3803616b9841102b4619c88c64356b6b540e56ce95919b8af9079c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / delocate-0.4.0-py33-none-any.whl

Download URL delocate-0.4.0-py33-none-any.whl
Size 62.9 kB
Tags Python 3.3
SHA-256 checksum
How to use checksums
1db1c5fee42df5cc9e01dbc132d8516ddf48cd9a3705a42d096048b8e7e52459
BLAKE2b-256 checksum
How to use checksums
6360ef632eed7db4b1b439a9c597cca0fa8421ee5e6e2e4642fb5febdbd90ad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / delocate-0.4.0-py2-none-any.whl

Download URL delocate-0.4.0-py2-none-any.whl
Size 62.9 kB
Tags Python 2
SHA-256 checksum
How to use checksums
0660332e314c952866d7c200d4b6b797ce962b033ebc6b2e911a931ce7bd83a7
BLAKE2b-256 checksum
How to use checksums
c1c2e7e5889f77018623de352c745e63dc0ebc09c3780343d631d4d4eb328f82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.7

2 release files

0.10.6

2 release files

0.10.5

2 release files

0.10.4

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.5

1 release file

0.6.4

3 release files

0.6.3

5 release files

0.6.2

5 release files

0.6.1

5 release files

0.6.0

4 release files

0.5.0

5 release files

This release

0.4.0 This release

5 release files

0.3.0

4 release files

0.2.1

4 release files

0.2.0

5 release files

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page