forked from SModelS/em-creator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hepmc2make.py
executable file
·63 lines (54 loc) · 1.89 KB
/
hepmc2make.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
#!/usr/bin/env python3
""" Simple script that handles the installation of hepmc2
"""
import subprocess, os, sys
ver="2.06.11"
tarball = f"hepmc{ver}.tgz"
path = f"HepMC-{ver}"
libraryname = f"{path}/fio/libHepMCfio.la"
includename = f"{path}/HepMC/HepMCDefs.h"
def fetchTarball():
""" fetch the hepmc2.06.11.tgz tarball """
if not os.path.exists ( tarball ):
cmd = f"wget https://smodels.github.io/downloads/tarballs/{tarball}"
o = subprocess.getoutput ( cmd )
print ( f"[hepmc2make] {cmd}: {o}" )
def explodeTarball():
""" fetch the tarball, then explode it """
fetchTarball()
if os.path.exists ( path ):
shutil.rmtree ( path )
cmd = f"tar xzvf {tarball}"
subprocess.getoutput ( cmd )
def makeHepmc2():
""" fetch the tarball, then explode it, then make hepmc2 """
explodeTarball()
cmd = f"cd {path}; ./configure --with-momentum=GEV --with-length=CM"
o = subprocess.getoutput ( cmd )
print ( f"[hepmc2make] {cmd}: {o}" )
cmd = f" cd {path}; make -j 2"
o = subprocess.getoutput ( cmd )
print ( f"[hepmc2make] {cmd}: {o}" )
def install():
if os.path.exists ( libraryname ) and os.path.exists ( includename ):
print ( f"[hepmc2make] not installing hepmc2: {libraryname} and {includename} exist" )
return
if os.path.exists ( path ):
## so path exists, but not the library. clean!
clean()
print ( "[hepmc2make] installing hepmc2 ..." )
makeHepmc2()
def clean():
import glob
for file in glob.glob ( "*" ):
if file not in [ "make.py", "Makefile" ]:
cmd = "rm -rf %s" % file
subprocess.getoutput ( cmd )
if __name__ == "__main__":
import inspect
D = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
os.chdir ( D )
if len(sys.argv)>1 and sys.argv[1]=="clean":
clean()
sys.exit()
install()