-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipython.sh
47 lines (38 loc) · 1.25 KB
/
ipython.sh
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
#!/bin/sh
if ! test -d "$CWD" ; then
echo "CWD is not set"
exit 1
fi
# if test -n "$DISPLAY"; then
# export QT_QPA_PLATFORM_PLUGIN_PATH=`echo ${pkgs.qt5.qtbase.bin}/lib/qt-*/plugins/platforms/`
# alias ipython='ipython --matplotlib=qt5 --profile-dir=$CWD/.ipython-profile'
# alias ipython0='ipython --profile-dir=$CWD/.ipython-profile'
# fi
mkdir $CWD/.ipython-profile 2>/dev/null || true
cat >$CWD/.ipython-profile/ipython_config.py <<EOF
c = get_config()
c.InteractiveShellApp.exec_lines = []
c.InteractiveShellApp.exec_lines.append('%load_ext autoreload')
c.InteractiveShellApp.exec_lines.append('%autoreload 2')
def tweak():
print("Enabling tweaks")
try:
import numpy as np
np.set_printoptions(edgeitems=30, linewidth=100000)
except Exception as e:
print("Failed to tweak numpy. Is it installed?")
try:
import ssl;
ssl._create_default_https_context = ssl._create_unverified_context
except Exception as e:
print("Failed to tweak ssl. Is it installed?")
try:
import matplotlib;
matplotlib.use('Qt5Agg');
import matplotlib.pyplot;
matplotlib.pyplot.ioff()
except Exception as e:
print("Failed to tweak matplotlib. Is it installed?")
tweak()
EOF
ipython3 --profile-dir=$CWD/.ipython-profile -i "$@"