-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path__init__.py
More file actions
33 lines (29 loc) · 1.15 KB
/
__init__.py
File metadata and controls
33 lines (29 loc) · 1.15 KB
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
32
33
import sys, site
from os.path import abspath, dirname, exists, join
from subprocess import call
try:
# test the sys.path by attempting to load a PyObjC submodule...
from Foundation import *
import objc
except ImportError:
# detect whether we're being run from the repository and set up a local env if so
repo = abspath(join(dirname(__file__), '../..'))
setup_py = '%s/setup.py' % repo
if exists(setup_py):
from platform import python_version
from sysconfig import get_config_var
local_libs = '%s/deps/local/%s/lib/python%s/site-packages' % (repo, python_version(), get_config_var('py_version_short'))
if not exists(local_libs):
call([sys.executable, setup_py, 'dev'])
site.addsitedir(local_libs)
from Foundation import *
import objc
else:
from pprint import pformat
missing = "Searched for PyObjC libraries in:\n%s\nto no avail..."%pformat(sys.path)
raise RuntimeError(missing)
# pull in the encoding-pragma detector
from .common import encoded
# expose the script-runner object
from .sandbox import Sandbox
__all__ = ('objc', 'encoded', 'Sandbox')