File tree 5 files changed +63
-0
lines changed
5 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ include README.rst
2
+ include machotools/tests/data/*dylib
Original file line number Diff line number Diff line change
1
+ Machoutils is a small set of tools built on top of macholib to retrieve and
2
+ change informations about mach-o files
3
+
4
+ Examples::
5
+
6
+ # Print the list of rpath defined in the given .dylib
7
+ python -m machotools list_rpaths foo.dylib
8
+
9
+ # Print the id (i.e. install_name) of the given .dylib
10
+ python -m machotools install_name foo.dylib
Original file line number Diff line number Diff line change
1
+ import sys
2
+
3
+ import argparse
4
+
5
+ from machotools .misc import install_name
6
+ from machotools .rpath import list_rpaths_from_file
7
+
8
+ def list_rpaths_command (namespace ):
9
+ rpaths = list_rpaths_from_file (namespace .macho )
10
+ if not len (rpaths ) == 1 :
11
+ raise ValueError ("Multi-arch files not supported yet !" )
12
+ else :
13
+ for rpath in rpaths [0 ]:
14
+ print rpath
15
+
16
+ def list_install_names (namespace ):
17
+ install_names = install_name (namespace .macho )
18
+ if not len (install_names ) == 1 :
19
+ raise ValueError ("Multi-arch files not supported yet !" )
20
+ else :
21
+ for name in install_names :
22
+ print name
23
+
24
+ def main (argv = None ):
25
+ if argv is None :
26
+ argv = sys .argv [1 :]
27
+
28
+ p = argparse .ArgumentParser ()
29
+ sub_parsers = p .add_subparsers (title = "sub commands" )
30
+
31
+ rpath = sub_parsers .add_parser ("list_rpaths" , help = "Manipulate rpaths" )
32
+ rpath .add_argument ("macho" , help = "Path to the mach-o to manipulate" )
33
+ rpath .set_defaults (func = list_rpaths_command )
34
+
35
+ install_name_parser = sub_parsers .add_parser ("install_name" , help = "Manipulate rpaths" )
36
+ install_name_parser .add_argument ("macho" , help = "Path to the mach-o to manipulate" )
37
+ install_name_parser .set_defaults (func = list_install_names )
38
+
39
+ namespace = p .parse_args (argv )
40
+ namespace .func (namespace )
41
+
42
+ if __name__ == "__main__" :
43
+ main ()
Original file line number Diff line number Diff line change
1
+ argparse
2
+ macholib >= 1.5.1
Original file line number Diff line number Diff line change
1
+ from setuptools import setup
2
+
3
+ if __name__ == "__main__" :
4
+ setup (name = "machotools" ,
5
+ version = "0.0.1" ,
6
+ packages = ["machotools" , "machotools.tests" ])
You can’t perform that action at this time.
0 commit comments