-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.m
More file actions
147 lines (110 loc) · 5.54 KB
/
install.m
File metadata and controls
147 lines (110 loc) · 5.54 KB
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
(* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
(* :Title: install *)
(*
This software is covered by the GNU Lesser General Public License 3.
Copyright (C) 2012-2016 Feng Feng
Copyright (C) 2012-2016 Rolf Mertig
Copyright (C) 2015-2016 Vladyslav Shtabovenko
*)
(* :Summary: Installs FeynCalcFormLink *)
(* ------------------------------------------------------------------------ *)
InstallFeynCalcFormLink::nofc =
"Looks like you don't have FeynCalc installed. FeynCalcFormLink cannot work without FeynCalc, so please \
install it first.";
InstallFeynCalcFormLink::nofl =
"Looks like you don't have FormLink installed. FeynCalcFormLink cannot work without FormLink, so please \
install it first.";
InstallFeynCalcFormLink::notcomp =
"Your Mathematica version is too old. FeynCalcFormLink requires at least Mathematica 8. Installation aborted!";
InstallFeynCalcFormLink::failed =
"Download of `1` failed. Installation aborted!";
AutoOverwriteFeynCalcFormLinkDirectory::usage="AutoOverwriteFeynCalcFormLinkDirectory is an option of InstallFeynCalcFormLink. If \
set to True, the existing FeynCalcFormLink 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.";
FeynCalcFormLinkDevelopmentVersionLink::usage="FeynCalcFormLinkDevelopmentVersionLink is an option of InstallFeynCalcFormLink. It specifies the url \
to the main repository of FeynCalcFormLink. This repository is used to install the development version of FeynCalcFormLink.";
FeynCalcFormLinkStableVersionLink::usage="FeynCalcFormLinkStableVersionLink is an option of InstallFeynCalcFormLink. It specifies the url \
to the latest stable release of FeynCalcFormLink.";
InstallFeynCalcFormLinkDevelopmentVersion::usage="InstallFeynCalcFormLinkDevelopmentVersion is an option of InstallFeynCalcFormLink. If \
set to True, the installer will download the latest development version of FeynCalcFormLink from the git repository. \
Otherwise it will install the latest stable version.";
InstallFeynCalcFormLinkTo::usage="InstallFeynCalcFormLinkTo is an option of InstallFeynCalcFormLink. It specifies, the full path \
to the directory where FeynCalcFormLink will be installed.";
If[ $VersionNumber == 8,
(*To use FetchURL in MMA8 we need to load URLTools first *)
Needs["Utilities`URLTools`"];
];
If [Needs["FeynCalc`"]===$Failed,
Message[InstallFeynCalcFormLink::nofc];
Abort[]
];
If [Needs["FormLink`"]===$Failed,
Message[InstallFeynCalcFormLink::nofl];
Abort[]
];
Options[InstallFeynCalcFormLink]={
AutoOverwriteFeynCalcFormLinkDirectory->None,
FeynCalcFormLinkDevelopmentVersionLink->"https://github.com/FormLink/feyncalcformlink/archive/master.zip",
(*for the moment there is no stable branch!*)
FeynCalcFormLinkStableVersionLink->"",
InstallFeynCalcFormLinkDevelopmentVersion->True,
InstallFeynCalcFormLinkTo->FileNameJoin[{$UserBaseDirectory, "Applications","FeynCalcFormLink"}]
};
InstallFeynCalcFormLink[OptionsPattern[]]:=
Module[{ unzipDir, tmpzip, gitzip, packageName, packageDir,
FCGetUrl, strOverwriteFCdit, zipDir},
If[OptionValue[InstallFeynCalcFormLinkDevelopmentVersion],
gitzip = OptionValue[FeynCalcFormLinkDevelopmentVersionLink];
zipDir = "feyncalcformlink-master",
gitzip = OptionValue[FeynCalcFormLinkStableVersionLink];
zipDir = "feyncalcformlink-stable"
];
packageName = "FeynCalcFormLink";
packageDir = OptionValue[InstallFeynCalcFormLinkTo];
strOverwriteFCdit="Looks like FeynCalcFormLink is already installed. Do you want to replace the content \
of " <> packageDir <> " with the downloaded version of FeynCalcFormLink? 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[InstallFeynCalcFormLink::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[AutoOverwriteFeynCalcFormLinkDirectory],
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 FeynCalcFormLink tarball *)
WriteString["stdout", "Downloading FeynCalcFormLink from ", gitzip," ..."];
tmpzip=FCGetUrl[gitzip];
unzipDir= tmpzip<>".dir";
WriteString["stdout", "done! \n"];
(* Extract to the content *)
WriteString["stdout", "FeynCalcFormLink zip file was saved to ", tmpzip,".\n"];
WriteString["stdout", "Extracting FeynCalcFormLink 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, " ..."];
Print[FileNameJoin[{unzipDir,zipDir}]];
CopyDirectory[FileNameJoin[{unzipDir,zipDir}],packageDir];
WriteString["stdout", "done! \n"];
(* Delete the extracted archive *)
Quiet@DeleteDirectory[unzipDir, DeleteContents -> True];
WriteString["stdout", "done! \n"];
WriteString["stdout","\nInstallation complete! To load FeynCalcFormLink, restart Mathematica \
and evaluate \n\n <<FeynCalcFormLink`"];
];