__init__.py 807 B

123456789101112131415161718192021222324
  1. import ctypes, os, sys
  2. def loadlibc():
  3. libc = None
  4. # os.environ['PATH'] = os.path.abspath(
  5. # os.path.join(
  6. # os.path.dirname(__file__), "../")) \
  7. # + ';' \
  8. # + os.environ['PATH']
  9. # __file__ is this __init__.py
  10. # This assumes that the repo's directory has not been modified
  11. # and that
  12. so = '/lib3ddevil1.so'
  13. libdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))
  14. sharedlib = libdir + so
  15. try:
  16. libc = ctypes.cdll.LoadLibrary(sharedlib)
  17. except OSError as e:
  18. print("Error loading dynamically linked library.\nOSError: " + str(e))
  19. raise RuntimeError("Couldn't load %s" % sharedlib)
  20. return libc
  21. libc = loadlibc()