[PYTHON] Introducing delocate, a wheel package utility for Mac OS X

This article is the 9th day of ** ADVENTAR ** Python Advent Calendar 2015, not Qiita.

What is delocate

delocate is a wheel package utility for OS X. Matthew Brett

It has the following functions

--Show the libraries that wheel depends on --Copy and rewrite dependent libraries in the wheel to link

Let me give you an example.

Display dependent libraries with the delocate-listdeps command

For an example, I will use the wheel file of the latest version of the cell simulator called E-Cell. If you want to build your own wheel file before delocate https://github.com/ecell/ecell4-wheels/blob/master/.travis.yml Please refer to before delocate

First try the delocate-listdeps command

> delocate-listdeps --all dist/ecell4-4.0.0b2-cp27-none-macosx_10_11_intel.whl      
/usr/lib/libSystem.B.dylib
/usr/lib/libc++.1.dylib
/usr/local/Cellar/gsl/1.16/lib/libgsl.0.dylib
/usr/local/Cellar/gsl/1.16/lib/libgslcblas.0.dylib
/usr/local/Cellar/hdf5/1.8.16/lib/libhdf5.10.dylib
/usr/local/Cellar/hdf5/1.8.16/lib/libhdf5_cpp.11.dylib

The wheel file ecell4-4.0.0b2-cp27-none-macosx_10_11_intel.whl is homebrew You can see that it depends on gsl and hdf5.

--allBy default with no options/usr/libWhen/systemDoes not show the libraries inside. (It seems that the libraries in them are common in OSX and you don't have to worry about them.)

Copying and relinking dependent libraries with the delocate-wheel command

Even if the above wheel package is distributed as it is

--I have homebrew installed in the default path --I have gsl version 1.16 and hdf5 1.8.16 installed --OSX version is 10.11

Only people can use it. (To be exact, only the third point is "I can't install the wheel" rather than not being able to use it. Details will be described later.)

This is because the wheel package expects the path confirmed by delocate-listdeps to the library to be dynamically linked.

The `` `delocate-wheel``` command rewrites this so that it does not depend on the environment. An example is shown.

> delocate-wheel dist/ecell4-4.0.0b2-cp27-none-macosx_10_11_intel.whl 
> delocate-listdeps dist/ecell4-4.0.0b2-cp27-none-macosx_10_11_intel.whl 
@loader_path/.dylibs/libgsl.0.dylib
@loader_path/.dylibs/libgslcblas.0.dylib
@loader_path/.dylibs/libhdf5.10.dylib
@loader_path/.dylibs/libhdf5_cpp.11.dylib
@loader_path/libhdf5.10.dylib
@loader_path/libsz.2.0.0.dylib

You can see that the delocate-wheel command moves dylib into the tree of expected path wheels. Not only has the expected path changed, but the dylib has been copied to be included in the wheel package. (You can see it by renaming whl to zip and unzipping it)

Add platform with delocate-addplat command

I was able to include the dependent libraries in the wheel with the delocate-wheel command, but the last issue remains that only "OS X version 10.11" mentioned above can be supported.

As specified in PEP 0427 This is because the last tag in the wheel filename indicates the platform. (Now this is macosx_10_11_intel.)

The command to add a platform to this is `` `delocate-addplat```. Here is an example.

> delocate-addplat --rm-orig -x 10_9 -x 10_10 dist/ecell4-4.0.0b2-cp27-none-macosx_10_11_intel.whl 
> ls dist/     
ecell4-4.0.0b2-cp27-none-macosx_10_11_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

You can see that the platform has been added.

Summary

I'm tired of putting it together, so that's it.

Recommended Posts

Introducing delocate, a wheel package utility for Mac OS X
Building an environment for "Tello_Video" on Mac OS X
Build a Python development environment on Mac OS X
Building a Python environment for programming beginners (Mac OS)
Memo on Mac OS X
Install Sphinx on Mac OS X
Installation of scikit-learn (Mac OS X)
Install mitmproxy on Mac OS X
Install pgmagick on Mac OS X 10.9
[Just a note] Until Keras + TensorFlow works on Mac OS X Sierra
Introduction to Graph Database Neo4j in Python for Beginners (for Mac OS X)
Mac OS X Mavericks 10.9.5 Development environment construction
Installed aws-cli On Mac OS X Lion
[Mac] Building a virtual environment for Python
Mac OS X Yosemite 10.10 Development environment construction
Mac OS X development environment construction memo
Run NASA CEA on Mac OS X
Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)