-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathrun.py
executable file
·65 lines (50 loc) · 1.62 KB
/
run.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
"""
Build and run bumps.
Usage:
./run.py [bumps cli args]
"""
import os
import sys
def addpath(path):
"""
Add a directory to the python path environment, and to the PYTHONPATH
environment variable for subprocesses.
"""
path = os.path.abspath(path)
if 'PYTHONPATH' in os.environ:
PYTHONPATH = path + os.pathsep + os.environ['PYTHONPATH']
else:
PYTHONPATH = path
os.environ['PYTHONPATH'] = PYTHONPATH
sys.path.insert(0, path)
from contextlib import contextmanager
@contextmanager
def cd(path):
old_dir = os.getcwd()
os.chdir(path)
yield
os.chdir(old_dir)
def prepare():
# Make sure that we have a private version of mplconfig
#mplconfig = os.path.join(os.getcwd(), '.mplconfig')
#os.environ['MPLCONFIGDIR'] = mplconfig
#if not os.path.exists(mplconfig):
# os.mkdir(mplconfig)
# To avoid cluttering the source tree with .pyc or __pycache__ files, you
# can suppress the bytecode generation when running in place. Unfortunately
# this is a pretty big performance hit on Windows, so we are going to
# suppress this behaviour and rely on .gitignore instead
#sys.dont_write_bytecode = True
#import numpy as np; np.seterr(all='raise')
root = os.path.abspath(os.path.dirname(__file__))
# Add the root to the system path
addpath(root)
# Make sample data and models available
os.environ['BUMPS_DATA'] = os.path.join(root, 'bumps', 'gui', 'resources')
if __name__ == "__main__":
import multiprocessing
multiprocessing.freeze_support()
prepare()
import bumps.cli
bumps.cli.main()