-
Notifications
You must be signed in to change notification settings - Fork 5
/
pathmaker.py
62 lines (52 loc) · 1.74 KB
/
pathmaker.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
import sys
import os
import traceback
import time
import subprocess
#moonpydir = os.path.realpath(__file__)
#moonpydir = moonpydir[:moonpydir.find('/pathmaker.py')]
def make_pathfile(moonpydir, install_pandora=True):
#### create the moonpy.pth file
os.system('touch '+moonpydir+'/moonpy.pth')
moonpy_pthfile = open(moonpydir+'/moonpy.pth', mode='w')
moonpy_pthfile.write(moonpydir)
moonpy_pthfile.close()
pythonpath = sys.executable
prepath = pythonpath[:pythonpath.find('/bin')]
libpath = prepath+'/lib'
libfiles = os.listdir(libpath)
for libfile in libfiles:
if libfile.startswith('python'):
pythonlib = libfile
break
pythonlibpath = libpath+'/'+pythonlib
site_packages_path = pythonlibpath+'/site-packages'
source_path = moonpydir+'/moonpy.pth'
destination_path = site_packages_path+'/moonpy.pth'
#### copy moonpy.pth to the site_packages_path
if os.path.exists(destination_path):
print(destination_path+' exists.')
else:
os.system('cp '+source_path+' '+destination_path)
print('copied '+source_path+' to '+destination_path)
if install_pandora == True:
#### set up Pandora
print('Attempting to install up PANDORA...')
print('if this hangs up, exit and try again!')
try:
try:
subprocess.run('rm -f '+site_packages_path+'/llvmlite*egg-info && pip install pandoramoon', shell=True, capture_output=True, text=True)
except:
print("could not delete the llvmlite egg-info file (maybe it doesn't exist!.")
subprocess.run('pip install pandoramoon', shell=True, capture_output=True, text=True)
except:
traceback.print_exc()
print(' ')
print(' ')
print('PANDORA installation failed.')
time.sleep(3)
print(' ')
print(' ')
make_pathfile(os.getcwd())
print('pathmaker.py exited successfully.')
print(' ')