- Notifications
You must be signed in to change notification settings - Fork3
Makes a macOS binary redistributable by searching the dependency tree and copying/patching non-system libraries.
License
chearon/macpack
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Bundles up all dependencies used by an executable (or library) into a singlefolder, and patches all of the executables to look in that directory so youdon't have to rely on your users having certain libraries installed.
Part of my motivation in making this was to learn Python 3'sasync/await, too. Theprocesses that are used to patch stuff and query dependencies all run inparallel so it should be super fast!
You need:
- Python 3 (
brew install python3
) because it uses async/await and asyncio - Xcode CLI tools (I think)
The easiest way to get going is by installing through pip + PyPi:
pip3 install macpackmacpack <your executable here>
You can also run it out of the project directory by doing:
macpack/patcher.py <your executable here>
It should print the dependency tree like this example:
$ macpack ~/Code/node-canvas/build/Release/canvas.nodePatching /Users/caleb/Code/node-canvas/build/Release/canvas.node16 total non-system dependencies1 libpixman-1.0.dylib -> 12 libcairo.2.dylib -> 2, 1, 16, 9, 33 libpng16.16.dylib -> 34 libpangocairo-1.0.0.dylib -> 4, 5, 2, 14, 6, 13, 7, 8, 15, 16, 95 libpango-1.0.0.dylib -> 5, 6, 13, 7, 86 libgobject-2.0.0.dylib -> 6, 7, 11, 12, 87 libglib-2.0.0.dylib -> 7, 11, 88 libintl.8.dylib -> 89 libfreetype.6.dylib -> 9, 310 libjpeg.8.dylib -> 1011 libpcre.1.dylib -> 1112 libffi.6.dylib -> 1213 libgthread-2.0.0.dylib -> 13, 7, 11, 814 libpangoft2-1.0.0.dylib -> 14, 5, 6, 13, 7, 8, 15, 16, 915 libharfbuzz.0.dylib -> 15, 7, 8, 916 libfontconfig.1.dylib -> 16, 9canvas.node + 16 dependencies successfully patched
Everything that your executable uses should then be copied into the same folderthat your binary is. When your main binary is run next, it will look in the newlocation you specified (default isbinary_dir/libs/<lib>
, see-d
below).Those dylibs will look in the same directory for dylibs they depend on, too, evenif your main binary does not use them.
You can then distribute the whole folder as one.
Pass-v
to get output fromotool
if it failed to patch or more information onwhich dependencies could not be loaded.
It will also print a more easy to read dependency tree, with the full names ofdependenies under each one
This is the destination folderrelative to the binary's containing folder tocopy library dependencies to. For example, if you binary is/a/b/program
,and you pass-d ../libraries
, they will copy to and load from/a/libraries/
. The default value is../libs
.
If you want the executable and libraries to have absolute paths instead of loadingrelative to the binary, you just need to specify an absolutep path for-d
. Inthat case the@executable_path
will not be put into the binaries at all.
Just prints the dependency tree and doesn't do any patching. Use-nv
to get aslightly more user-friendly tree printed out.
It will parse out the executable's dependencies (usingotool -L
) and theirdependencies recursively, filtering out system libraries. When the treeis built, it will copy the libraries to your program's folder and then patcheverything that it is aware of (usinginstall_name_tool
). It should be ableto handle different symbolic links and all that correctly
Inspired bymacdylibbundler, it doesthe same basic thing except with less options (at the moment) and it builds a fulldependency tree
About
Makes a macOS binary redistributable by searching the dependency tree and copying/patching non-system libraries.