From 360de0dea55f86c52abd24c5e1e03d9a790f2a8e Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 17 May 2018 14:00:52 -0700 Subject: [PATCH 1/4] declared function where del sharedlib is not needed anymore --- bindings/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bindings/__init__.py b/bindings/__init__.py index a5d2c47..b49dc36 100644 --- a/bindings/__init__.py +++ b/bindings/__init__.py @@ -1,11 +1,12 @@ import ctypes -sharedlib = './lib3ddevil1.so' -try: - libc = ctypes.cdll.LoadLibrary(sharedlib) -except OSError as e: - print("Error loading dynamically linked library.\nOSError: " + str(e)) - raise SystemExit("Couldn't load %s" % sharedlib) +def loadlibc(): + sharedlib = './lib3ddevil1.so' + libc = None + try: + libc = ctypes.cdll.LoadLibrary(sharedlib) + except OSError as e: + print("Error loading dynamically linked library.\nOSError: " + str(e)) + raise SystemExit("Couldn't load %s" % sharedlib) -# Don't need these anymore -del sharedlib +libc = loadlibc() \ No newline at end of file From 911a1ad840010ea8d8f8c5e422b14ba3287c8423 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 17 May 2018 15:07:17 -0700 Subject: [PATCH 2/4] Added return statement for fn in __init__ --- bindings/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/__init__.py b/bindings/__init__.py index b49dc36..6a1ff15 100644 --- a/bindings/__init__.py +++ b/bindings/__init__.py @@ -8,5 +8,6 @@ def loadlibc(): except OSError as e: print("Error loading dynamically linked library.\nOSError: " + str(e)) raise SystemExit("Couldn't load %s" % sharedlib) + return libc libc = loadlibc() \ No newline at end of file From 9b9f0bd6ee316b78a824e3e2a7b37103cfb48b92 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 17 May 2018 15:20:39 -0700 Subject: [PATCH 3/4] Fixed issues caused by importing from __init__ statements --- bindings/py3devil1geo.py | 8 +++++++- bindings/py3devil1pld.py | 9 ++++++++- bindings/py3devil1tex.py | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/bindings/py3devil1geo.py b/bindings/py3devil1geo.py index e1bdd9e..5757b6a 100644 --- a/bindings/py3devil1geo.py +++ b/bindings/py3devil1geo.py @@ -1,5 +1,11 @@ import ctypes -from __init__ import libc +import os, sys +sys.path.append( + os.path.abspath( + os.path.join( + os.path.dirname(__file__), "../../"))) +from lib3ddevil1.bindings import libc +del os, sys #--------------------------------------+ # Basic Struct diff --git a/bindings/py3devil1pld.py b/bindings/py3devil1pld.py index 62ed79b..a16c8c5 100644 --- a/bindings/py3devil1pld.py +++ b/bindings/py3devil1pld.py @@ -1,5 +1,12 @@ import ctypes -from __init__ import libc +import os, sys +# This is the folder containing the whole library. +sys.path.append( + os.path.abspath( + os.path.join( + os.path.dirname(__file__), "../../"))) +from lib3ddevil1.bindings import libc +del os, sys #--------------------------------------+ # Basic Struct diff --git a/bindings/py3devil1tex.py b/bindings/py3devil1tex.py index 6300ed1..4c67368 100644 --- a/bindings/py3devil1tex.py +++ b/bindings/py3devil1tex.py @@ -1,5 +1,11 @@ import ctypes -from __init__ import libc +import os, sys +sys.path.append( + os.path.abspath( + os.path.join( + os.path.dirname(__file__), "../../"))) +from lib3ddevil1.bindings import libc +del os, sys #--------------------------------------+ # Basic Struct From e63ddfb8383a1fd753a1cb1287a9a24eb64e2bc8 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 17 May 2018 15:28:28 -0700 Subject: [PATCH 4/4] Added library to path to search for .so --- bindings/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bindings/__init__.py b/bindings/__init__.py index 6a1ff15..9675198 100644 --- a/bindings/__init__.py +++ b/bindings/__init__.py @@ -1,8 +1,13 @@ -import ctypes +import ctypes, os, sys def loadlibc(): sharedlib = './lib3ddevil1.so' libc = None + os.environ['PATH'] = os.path.abspath( + os.path.join( + os.path.dirname(__file__), "../")) \ + + ';' \ + + os.environ['PATH'] try: libc = ctypes.cdll.LoadLibrary(sharedlib) except OSError as e: @@ -10,4 +15,4 @@ def loadlibc(): raise SystemExit("Couldn't load %s" % sharedlib) return libc -libc = loadlibc() \ No newline at end of file +libc = loadlibc()