-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·156 lines (138 loc) · 5.32 KB
/
setup.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env python3
"""
.. module:: setup
:synopsis: Setup script for SModelS.
.. moduleauthor:: Wolfgang Waltenberger <[email protected]>
"""
import os
import sys
from setuptools import setup, Extension
from setuptools.command.install import install
sys.path.insert ( 0, "./" )
from smodels.installation import version, authors, requirements, resolve_dependencies, fixpermissions
import subprocess
class OverrideInstall(install):
def run(self):
#uid, gid = 0, 0
install.run(self) # calling install.run(self) insures that everything
# that happened previously still happens,
install_as_user = True
try:
import getpass
if getpass.getuser() == "root":
install_as_user = False
except Exception as e:
pass
enableStupidMacFix=False
if enableStupidMacFix:
if "Apple" in sys.version:
# a wild attempt at fixing a problem with Mac OS X. Somehow
# setup.py doesnt resolve the requirements!
try:
self.do_egg_install()
except Exception as e:
pass
# so the installation does not break!
# here we start with doing our overriding and private magic ..
mode = 0o777
for filepath in self.get_outputs():
# if self.install_scripts in filepath:
if "smodels/lib/" in filepath:
#print ("Overriding setuptools mode of scripts ...")
#log.info("Changing ownership of %s to uid:%s gid %s" %
# (filepath, uid, gid))
#os.chown(filepath, uid, gid)
# print ("Changing permissions of %s to %s" %
# ( os.path.dirname ( filepath ), oct(mode)))
os.chmod( os.path.dirname ( filepath ), mode )
if install_as_user: ## FIXME doesnt work for system installs
resolve_dependencies( as_user=install_as_user )
if not install_as_user:
fixpermissions()
def read(fname):
"""
Simple method to read a file (fname) located in the current folder.
"""
return open(os.path.join(os.path.dirname(__file__), fname)).read()
def listDirectory (dirname):
""" list all files in directory, skip subdirs """
if dirname[-1] == "/":
dirname = dirname[:-1]
files = os.listdir (dirname)
ret = []
for file in files:
fullname = dirname + "/" + file
extension = os.path.splitext ( file )[1]
if os.path.isdir ( fullname ) or \
extension in [ ".out", ".tgz", ".1" ] or \
file in [ "Makefile", "README" ]:
continue
ret.append ( fullname )
return ret
def dataFiles ():
"""
List all config files and binaries
"""
ret = []
ret.append ( ("smodels/", [ "smodels/version", "smodels/COPYING", "smodels/README.rst", "smodels/INSTALLATION.rst" ]) )
for directory in [ "smodels/share/", "smodels/share/models/",
"smodels/etc/", "smodels/lib/nllfast/nllfast-1.2/",
"smodels/lib/nllfast/nllfast-2.1/", "smodels/lib/nllfast/nllfast-3.1/",
"smodels/lib/pythia6/", "smodels/lib/pythia8/", "smodels/lib/resummino/" ]:
ret.append ((directory, listDirectory (directory)))
for directory in ["inputFiles/slha/", "inputFiles/lhe/" ]:
ret.append (( "smodels/"+directory, listDirectory (directory)))
return ret
def compile():
"""
Compile external tools by calling make
"""
import sys
if len(sys.argv) < 2:
return
needs_build = False
for i in sys.argv[1:]:
if i in [ "build", "build_ext", "build_clib", "install",
"install_lib", "bdist", "bdist_rpm", "bdist_dumb",
"bdist_wininst", "bdist_wheel", "develop"]:
needs_build = True
if not needs_build:
return
subprocess.call(["make", "-C", "smodels/lib" ])
# compile() ## not needed anymore as we perform compilation-on-demand now
setup(
name = "smodels",
version = version(),
author = authors(),
author_email="[email protected] ",
entry_points = {
'console_scripts': ['smodels-config=smodels.installation:main',
'runSModelS.py=smodels.tools.runSModelS:main',
'smodelsTools.py=smodels.tools.smodelsTools:main' ]
},
install_requires=requirements(),
data_files=dataFiles() ,
description=("A tool for interpreting simplified-model results from the "
"LHC"),
cmdclass={'install': OverrideInstall},
license="GPLv3",
# use_2to3 = True,
keywords=("simplified models LHC BSM theories interpretation "
"supersymmetry UEDs"),
url="http://smodels.github.io/",
packages=['smodels',
'smodels.decomposition',
'smodels.matching',
'smodels.tools',
'smodels.base',
'smodels.statistics',
'smodels.experiment'],
include_package_data = True,
test_suite='test',
long_description=read('smodels/README.rst'),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Topic :: Scientific/Engineering :: Physics",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]
)