3 # Python wrapper, which makes it able to import the built (and not the
4 # installed) version of libjio.
6 # The first parameter must be the python version (2 or 3)
13 if len(sys
.argv
) < 2 or sys
.argv
[1] not in ("2", "3"):
14 sys
.stderr
.write("Error: the first argument must be the " +
21 # Find the path where the library was built and add it to the lookup paths, so
23 lib_bin
= os
.path
.dirname(sys
.argv
[0]) + "/../../libjio/build/libjio.so"
25 if not os
.path
.exists(lib_bin
):
26 sys
.stderr
.write("Can't find library (run make)\n")
29 lib_path
= os
.path
.dirname(os
.path
.abspath(lib_bin
))
30 os
.environ
["LD_LIBRARY_PATH"] = ":".join([lib_path
, \
31 os
.environ
.get("LD_LIBRARY_PATH", "")])
34 # Find out the corresponding module path for the desired python version. The
35 # path must be absolute
36 mod_bins
= glob
.glob(os
.path
.dirname(sys
.argv
[0]) +
37 "/../../bindings/python/build/lib*-%s.*/libjio.so" \
40 sys
.stderr
.write(("Can't find python%s bindings, run " +
41 "make python%s\n") % (py_ver
, py_ver
))
45 sys
.stderr
.write("Found too many matching python%s bindings" \
49 mod_path
= os
.path
.dirname(os
.path
.abspath(mod_bins
[0]))
50 os
.environ
["PYTHONPATH"] = ":".join([mod_path
,
51 os
.environ
.get("PYTHONPATH", "")])
58 os
.execvp(py_bin
, [py_bin
] + sys
.argv
[2:])