This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
forked from FeynCalc/feynhelpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.m
324 lines (246 loc) · 12.5 KB
/
install.m
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
(* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
(* :Title: install *)
(*
This software is covered by the GNU General Public License 3.
Copyright (C) 2014-2018 Vladyslav Shtabovenko
*)
(* :Summary: Installs FeynHelpers *)
(* ------------------------------------------------------------------------ *)
InstallFeynHelpers::nofc =
"Looks like you don't have FeynCalc installed. FeynHelpers cannot work without FeynCalc, so please \
install it first.";
InstallFeynHelpers::notcomp =
"Your Mathematica version is too old. FeynHelpers requires at least Mathematica 8. Installation aborted!";
InstallFeynHelpers::failed =
"Download of `1` failed. Installation aborted!";
AutoOverwriteFeynHelpersDirectory::usage="AutoOverwriteFeynHelpersDirectory is an option of InstallFeynHelpers. If \
set to True, the existing FeynHelpers directory will be deleted without any further notice. The default
value None means that the user will be asked by a dialog. False means that the directory will be overwritten.";
AutoOverwritePackageXDirectory::usage="AutoOverwritePackageXDirectory is an option of InstallPackageX. If \
set to True, the existing Package-X directory will be deleted without any further notice. The default
value None means that the user will be asked by a dialog. False means that the directory will be overwritten.";
AutoDisableInsufficientVersionWarning::usage="AutoDisableInsufficientVersionWarning is an option of InstallFeynHelpers. If \
set to True, warning messages for notebooks that were created with a newer Mathematica version will be silently disabled. \
This is needed to use FeynHelpers documentation in Mathematica 8 and 9, since otherwise the warning message will appear every \
time one opens a help page for a FeynHelpers function. The default value None means that the user will be asked by a dialog. \
False means that the warning will not be disabled.";
FeynHelpersDevelopmentVersionLink::usage="FeynHelpersDevelopmentVersionLink is an option of InstallFeynHelpers. It specifies the url \
to the main repository of FeynHelpers. This repository is used to install the development version of FeynHelpers.";
FeynHelpersStableVersionLink::usage="FeynHelpersStableVersionLink is an option of InstallFeynHelpers. It specifies the url \
to the latest stable release of FeynHelpers.";
InstallFeynHelpersDevelopmentVersion::usage="InstallFeynHelpersDevelopmentVersion is an option of InstallFeynHelpers. If \
set to True, the installer will download the latest development version of FeynHelpers from the git repository. \
Otherwise it will install the latest stable version.";
InstallFeynHelpersTo::usage="InstallFeynHelpersTo is an option of InstallFeynHelpers. It specifies, the full path \
to the directory where FeynHelpers will be installed.";
AutoInstallPackageX::usage="AutoInstallPackageX is an option of InstallFeynHelpers. If \
set to True, Package-X will be installed automatically.";
AutoInstallFIRE::usage="AutoInstallFIRE is an option of InsInstallFeynHelpers. If \
set to True, Package-X will be installed automatically.";
If[ $VersionNumber == 8,
(*To use FetchURL in MMA8 we need to load URLTools first *)
Needs["Utilities`URLTools`"];
];
If [Needs["FeynCalc`"]===$Failed,
Message[InstallFeynHelpers::nofc];
Abort[]
];
Options[InstallFeynHelpers]={
AutoInstallPackageX->None,
AutoInstallFIRE->None,
AutoOverwriteFeynHelpersDirectory->None,
FeynHelpersDevelopmentVersionLink->"https://github.com/FeynCalc/feynhelpers/archive/master.zip",
FeynHelpersStableVersionLink->"https://github.com/FeynCalc/feynhelpers/archive/stable.zip",
InstallFeynHelpersDevelopmentVersion->False,
InstallFeynHelpersTo->FileNameJoin[{$FeynCalcDirectory, "AddOns","FeynHelpers"}]
};
Options[InstallPackageX]={
AutoOverwritePackageXDirectory -> None,
PackageXLink->"http://www.hepforge.org/archive/packagex/X-2.1.0.zip",
InstallPackageXTo->FileNameJoin[{$UserBaseDirectory, "Applications","X"}]
};
Options[InstallFIRE]={
AutoOverwriteFIREDirectory -> None,
FIRELink->"https://bitbucket.org/feynmanIntegrals/fire/downloads/FIRE5.2.tar.gz",
InstallFIRETo->FileNameJoin[{$UserBaseDirectory, "Applications","FIRE5"}]
};
InstallPackageX[OptionsPattern[]]:=
Module[{tmpzip,zip,FCGetUrl,unzipDir,packageDir,packageName,strOverwriteFCdit},
(* Install PackageX *)
packageDir=OptionValue[InstallPackageXTo];
zip = OptionValue[PackageXLink];
packageName = "Package-X";
strOverwriteFCdit="Looks like " <> packageName <> " is already installed. Do you want to replace the content \
of " <> packageDir <> " with the downloaded version of " <> packageName <> "? If you are using any custom configuration \
files or add-ons that are located in that directory, please backup them in advance.";
If[$VersionNumber == 8,
(*To use FetchURL in MMA8 we need to load URLTools first *)
FCGetUrl[x_]:= Utilities`URLTools`FetchURL[x],
FCGetUrl[x_]:= URLSave[x,CreateTemporary[]]
];
(* If the package directory already exists, ask the user about overwriting *)
If[ DirectoryQ[packageDir],
If[ OptionValue[AutoOverwritePackageXDirectory],
Quiet@DeleteDirectory[packageDir, DeleteContents -> True],
Null,
If[ ChoiceDialog[strOverwriteFCdit,{"Yes, overwrite the " <> packageName <>" directory"->True,
"No! I need to do a backup first."->False}],
Quiet@DeleteDirectory[packageDir, DeleteContents -> True],
Abort[]
]
]
];
WriteString["stdout", "Downloading Package-X from ", zip," ..."];
tmpzip=FCGetUrl[zip];
unzipDir= tmpzip<>".dir";
WriteString["stdout", "done! \n"];
(* Extract to the content *)
WriteString["stdout", "Package-X zip file was saved to ", tmpzip,".\n"];
WriteString["stdout", "Extracting Package-X zip file to ", unzipDir, " ..."];
ExtractArchive[tmpzip, unzipDir];
WriteString["stdout", "done! \n"];
(* Move the files to the final destination *)
WriteString["stdout", "Copying Package-X to ", packageDir, " ..."];
CopyDirectory[FileNameJoin[{unzipDir,"X"}],packageDir];
WriteString["stdout", "done! \n"];
(* Delete the downloaded file *)
Quiet@DeleteFile[tmpzip];
(* Delete the extracted archive *)
Quiet@DeleteDirectory[unzipDir, DeleteContents -> True];
];
InstallFIRE[OptionsPattern[]]:=
Module[{tmpzip,zip,FCGetUrl,unzipDir,packageDir,packageName,strOverwriteFCdit},
(* Install PackageX *)
packageDir=OptionValue[InstallFIRETo];
zip = OptionValue[FIRELink];
packageName = "FIRE";
strOverwriteFCdit="Looks like " <> packageName <> " is already installed. Do you want to replace the content \
of " <> packageDir <> " with the downloaded version of " <> packageName <> "? If you are using any custom configuration \
files or add-ons that are located in that directory, please backup them in advance.";
If[$VersionNumber == 8,
(*To use FetchURL in MMA8 we need to load URLTools first *)
FCGetUrl[x__]:= Utilities`URLTools`FetchURL[x],
FCGetUrl[x__]:= URLSave[x,CreateTemporary[]]
];
(* If the package directory already exists, ask the user about overwriting *)
If[ DirectoryQ[packageDir],
If[ OptionValue[AutoOverwriteFIREDirectory],
Quiet@DeleteDirectory[packageDir, DeleteContents -> True],
Null,
If[ ChoiceDialog[strOverwriteFCdit,{"Yes, overwrite the " <> packageName <>" directory"->True,
"No! I need to do a backup first."->False}],
Quiet@DeleteDirectory[packageDir, DeleteContents -> True],
Abort[]
]
]
];
WriteString["stdout", "Downloading FIRE from ", zip," ..."];
If[$VersionNumber == 8,
(* https://mathematica.stackexchange.com/questions/129519/urlsave-and-bitbucket *)
tmpzip=Utilities`URLTools`FetchURL[zip, Utilities`URLTools`FileFilters -> {}, "RequestHeaderFields" -> {"Content-Type" -> ""}],
tmpzip=URLSave[zip, CreateTemporary[], "Headers" -> {"Content-Type" -> ""}]
];
unzipDir= tmpzip<>".dir";
WriteString["stdout", "done! \n"];
(* Extract to the content *)
WriteString["stdout", "FIRE tarball was saved to ", tmpzip,".\n"];
WriteString["stdout", "Extracting FIRE tarball to ", unzipDir, " ..."];
ExtractArchive[First[ExtractArchive[tmpzip, tmpzip<>".tmp"]], unzipDir];
WriteString["stdout", "done! \n"];
(* Move the files to the final destination *)
WriteString["stdout", "Copying FIRE to ", packageDir, " ..."];
CopyDirectory[FileNameJoin[{unzipDir,"fire","FIRE5"}],packageDir];
WriteString["stdout", "done! \n"];
(* Delete the downloaded file *)
Quiet@DeleteFile[tmpzip];
(* Delete the extracted archive *)
Quiet@DeleteDirectory[unzipDir, DeleteContents -> True];
];
InstallFeynHelpers[OptionsPattern[]]:=
Module[{ unzipDir, tmpzip, gitzip, packageName, packageDir,
strPackageX,strFIRE,FCGetUrl,
strOverwriteFCdit, xInstalled, fireInstalled, zipDir},
If[OptionValue[InstallFeynHelpersDevelopmentVersion],
gitzip = OptionValue[FeynHelpersDevelopmentVersionLink];
zipDir = "feynhelpers-master",
gitzip = OptionValue[FeynHelpersStableVersionLink];
zipDir = "feynhelpers-stable"
];
xInstalled=False;
fireInstalled=False;
packageName = "FeynHelpers";
packageDir = OptionValue[InstallFeynHelpersTo];
strPackageX="Do you want to install Package-X from "<> OptionValue[InstallPackageX,PackageXLink] <> "? Package-X is a \
Mathematica package for 1-loop calculations written by Hiren Patel (packagex.hepforge.org, arXiv:1503.01469). It contains \
a library of analytic expression for Passarino-Veltman functions that can be accessed via FeynHelpers. This allows you to \
evaluate such integrals directly in your FeynCalc session. Without Package-X you cannot use FeynHelpers' PaXEvaluate function. \
Before you proceed, please look at the license of Package-X and make sure that you understand it and that you agree with it.";
strFIRE="Do you want to install FIRE 5.2 from "<> OptionValue[InstallFIRE,FIRELink] <> "? FIRE is a \
Mathematica package for IBP reduction of loop integrals developed by Alexander Smirnov (bitbucket.org/feynmanIntegrals/fire, \
arXiv:1408.2372). The capabilities of FIRE can be accessed via FeynHelpers. This allows you to IBP-reduce loop integrals directly \
in your FeynCalc session. Without FIRE you cannot use FeynHelpers' FIREBurn function. Before you proceed, please look at the license of \
FIRE and make sure that you understand it and that you agree with it.";
strOverwriteFCdit="Looks like FeynHelpers is already installed. Do you want to replace the content \
of " <> packageDir <> " with the downloaded version of FeynHelpers? If you are using any custom configuration \
files or add-ons that are located in that directory, please backup them in advance.";
If[$VersionNumber < 8,
Message[InstallFeynHelpers::notcomp];
Abort[]
];
If[$VersionNumber == 8,
(*To use FetchURL in MMA8 we need to load URLTools first *)
FCGetUrl[x_]:= Utilities`URLTools`FetchURL[x],
FCGetUrl[x_]:= URLSave[x,CreateTemporary[]]
];
(* If the package directory already exists, ask the user about overwriting *)
If[ DirectoryQ[packageDir],
If[ OptionValue[AutoOverwriteFeynHelpersDirectory],
Quiet@DeleteDirectory[packageDir, DeleteContents -> True],
Null,
If[ ChoiceDialog[strOverwriteFCdit,{"Yes, overwrite the " <> packageName <>" directory"->True,
"No! I need to do a backup first."->False}],
Quiet@DeleteDirectory[packageDir, DeleteContents -> True],
Abort[]
]
]
];
(* Download FeynHelpers tarball *)
WriteString["stdout", "Downloading FeynHelpers from ", gitzip," ..."];
tmpzip=FCGetUrl[gitzip];
unzipDir= tmpzip<>".dir";
WriteString["stdout", "done! \n"];
(* Extract to the content *)
WriteString["stdout", "FeynHelpers zip file was saved to ", tmpzip,".\n"];
WriteString["stdout", "Extracting FeynHelpers zip file to ", unzipDir, " ..."];
ExtractArchive[tmpzip, unzipDir];
WriteString["stdout", "done! \n"];
(* Delete the downloaded file *)
Quiet@DeleteFile[tmpzip];
(* Move the files to the final destination *)
WriteString["stdout", "Copying "<>packageName<>" to ", packageDir, " ..."];
CopyDirectory[FileNameJoin[{unzipDir,zipDir}],packageDir];
WriteString["stdout", "done! \n"];
(* Delete the extracted archive *)
Quiet@DeleteDirectory[unzipDir, DeleteContents -> True];
WriteString["stdout", "done! \n"];
If[ OptionValue[AutoInstallPackageX],
xInstalled=True;
InstallPackageX[],
Null,
If[ ChoiceDialog[strPackageX],
xInstalled=True;
InstallPackageX[]
]
];
If[ OptionValue[AutoInstallFIRE],
fireInstalled=True;
InstallFIRE[],
Null,
If[ ChoiceDialog[strFIRE],
fireInstalled=True;
InstallFIRE[]
]
];
WriteString["stdout","\nInstallation complete! To load FeynHelpers, restart Mathematica \
and evaluate \n\n $LoadAddOns={\"FeynHelpers\"}; \n\n before you load FeynCalc; \n"];
];