Skip to main content

Move OSX dynamic libraries into package

Project description

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).

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

delocate-0.2.0.zip (60.4 kB view details)

Uploaded Source

delocate-0.2.0.tar.gz (45.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

delocate-0.2.0-py34-none-any.whl (57.1 kB view details)

Uploaded Python 3.4

delocate-0.2.0-py33-none-any.whl (57.1 kB view details)

Uploaded Python 3.3

delocate-0.2.0-py27-none-any.whl (57.2 kB view details)

Uploaded Python 2.7

File details

Details for the file delocate-0.2.0.zip.

File metadata

  • Download URL: delocate-0.2.0.zip
  • Upload date:
  • Size: 60.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for delocate-0.2.0.zip
Algorithm Hash digest
SHA256 f84978d708d2c5c1c429d5e4d9a7afd5478464cdc3fa5c1dfee0fca9924e4ad4
MD5 f50c2ee3eac173adde2020a2029a7a7d
BLAKE2b-256 dc9dd2a23c9d173ecc0fa212020b29ffce103cbff8dcbfd5325bacdac62104a3

See more details on using hashes here.

File details

Details for the file delocate-0.2.0.tar.gz.

File metadata

  • Download URL: delocate-0.2.0.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for delocate-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4ecd1553535383a6fd0720c593e30dc28737567e35614a7f0d3cd9fc2866ac2b
MD5 aa76eba2b0f4ad1a1a5c55181c116896
BLAKE2b-256 baa583e96afeebdf30ade8595b19d2d5cd3e58ce5bb0e5995c710c18b19dfe88

See more details on using hashes here.

File details

Details for the file delocate-0.2.0-py34-none-any.whl.

File metadata

File hashes

Hashes for delocate-0.2.0-py34-none-any.whl
Algorithm Hash digest
SHA256 ee3dc983976dbd6b203da3f7b569db28825d95de168456eff575e9ebeecac503
MD5 09b84bd94e69e77e863f3d2b47ed26f8
BLAKE2b-256 ce85988b08374dd46fc52abed6ee58436a669bd006f33a757b7d0f31436e7257

See more details on using hashes here.

File details

Details for the file delocate-0.2.0-py33-none-any.whl.

File metadata

File hashes

Hashes for delocate-0.2.0-py33-none-any.whl
Algorithm Hash digest
SHA256 ca2279122ad761bb752c89ff719ef17ebe04b3d83d1b48496d91df79c02733af
MD5 10722c5661eec5c4d960df08e1991cc0
BLAKE2b-256 f0d06194c317ed49f3284c842e2edcbda33e584ca0ccc75c23b4200a7ff8cf3a

See more details on using hashes here.

File details

Details for the file delocate-0.2.0-py27-none-any.whl.

File metadata

File hashes

Hashes for delocate-0.2.0-py27-none-any.whl
Algorithm Hash digest
SHA256 e059410290e94f032eba2de578a1c3f2c491c4c406bacd9de0acedce68134a6d
MD5 b13581bfa4d952808c2936bb06db9dd0
BLAKE2b-256 83707155fb4a2d3b7da3b7f68be1374cdfecb3b17db8fdc95a9c9d0c0006b1ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page