Skip to content

Commit

Permalink
Move external library handling into ext/
Browse files Browse the repository at this point in the history
With more and more different (external) libraries, the main aardvark.py
gets very cluttered. Move the library handling into ext/__init__.py.

Signed-off-by: Michael Walle <[email protected]>
  • Loading branch information
mwalle committed Mar 28, 2024
1 parent 0a574e0 commit 15d7d72
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
34 changes: 2 additions & 32 deletions pyaardvark/aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,10 @@
from builtins import bytes
import array
import logging
import sys

from .constants import *

if sys.platform.startswith('linux'):
try:
from .ext.linux32 import aardvark as api
except ImportError:
try:
from .ext.linux64 import aardvark as api
except ImportError:
api = None
elif sys.platform.startswith('win32'):
try:
from .ext.win32 import aardvark as api
except ImportError:
try:
from .ext.win64 import aardvark as api
except ImportError:
api = None
elif sys.platform.startswith('darwin'):
try:
from .ext.osx64 import aardvark as api
except ImportError:
try:
from .ext.osxarm import aardvark as api
except ImportError:
api = None
else:
api = None

if not api:
raise RuntimeError('Unable to find suitable binary interface. '
'Unsupported platform?')
from .constants import *
from .ext import api

log = logging.getLogger(__name__)

Expand Down
32 changes: 32 additions & 0 deletions pyaardvark/ext/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys

if sys.platform.startswith('linux'):
try:
from .linux32 import aardvark as api
except ImportError:
try:
from .linux64 import aardvark as api
except ImportError:
api = None
elif sys.platform.startswith('win32'):
try:
from .win32 import aardvark as api
except ImportError:
try:
from .win64 import aardvark as api
except ImportError:
api = None
elif sys.platform.startswith('darwin'):
try:
from .osx64 import aardvark as api
except ImportError:
try:
from .osxarm import aardvark as api
except ImportError:
api = None
else:
api = None

if not api:
raise RuntimeError('Unable to find suitable binary interface. '
'Unsupported platform?')

0 comments on commit 15d7d72

Please sign in to comment.