forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsite.py
More file actions
31 lines (21 loc) · 902 Bytes
/
site.py
File metadata and controls
31 lines (21 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import os
from importlib.abc import Loader, MetaPathFinder
from importlib.machinery import ModuleSpec
from importlib import _bootstrap_external
sys.platform = "android"
class AndroidExtensionFinder(MetaPathFinder):
@classmethod
def find_spec(cls, fullname, path=None, target=None):
soname = 'libpy.' + fullname + '.so'
path = os.path.join(sys._native_library_dir, soname)
if os.path.exists(path):
loader = _bootstrap_external.ExtensionFileLoader(fullname, path)
return ModuleSpec(fullname, loader, origin=path)
def main():
"""Adds the site-packages directory to the sys.path.
Also, registers the import hook for extension modules."""
sys.path.append('{0}/lib/python{1}.{2}/site-packages'.format(sys.prefix, *sys.version_info))
sys.meta_path.append(AndroidExtensionFinder)
if not sys.flags.no_site:
main()