-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathPyPackage.Manager.Cmd.Pip.Install.pas
More file actions
355 lines (309 loc) · 12.8 KB
/
PyPackage.Manager.Cmd.Pip.Install.pas
File metadata and controls
355 lines (309 loc) · 12.8 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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
(**************************************************************************)
(* *)
(* Module: Unit 'PyPackage.Manager.Cmd.Pip.Install' *)
(* *)
(* Copyright (c) 2021 *)
(* Lucas Moura Belo - lmbelo *)
(* lucas.belo@live.com *)
(* Brazil *)
(* *)
(* Project page: https://github.com/lmbelo/P4D_AI_ML *)
(**************************************************************************)
(* Functionality: PyPackage Cmd layer *)
(* *)
(* *)
(**************************************************************************)
(* This source code is distributed with no WARRANTY, for no reason or use.*)
(* Everyone is allowed to use and change this code free for his own tasks *)
(* and projects, as long as this header and its copyright text is intact. *)
(* For changed versions of this code, which are public distributed the *)
(* following additional conditions have to be fullfilled: *)
(* 1) The header has to contain a comment on the change and the author of *)
(* it. *)
(* 2) A copy of the changed source has to be sent to the above E-Mail *)
(* address or my then valid address, if this is possible to the *)
(* author. *)
(* The second condition has the target to maintain an up to date central *)
(* version of the component. If this condition is not acceptable for *)
(* confidential or legal reasons, everyone is free to derive a component *)
(* or to generate a diff file to my or other original sources. *)
(**************************************************************************)
unit PyPackage.Manager.Cmd.Pip.Install;
interface
uses
System.SysUtils, System.Classes, System.Generics.Collections,
PyPackage.Manager.Defs.Opts.Pip.Install;
type
TPyPackageManagerCmdPipInstall = class
private
FOpts: TPyPackageManagerDefsOptsPipInstall;
public
constructor Create(const ADefs: TPyPackageManagerDefsOptsPipInstall);
function MakeInstallRequirementCmd: TArray<string>; inline;
function MakeInstallConstraintCmd: TArray<string>; inline;
function MakeInstallNoDepsCmd: TArray<string>; inline;
function MakeInstallPreCmd: TArray<string>; inline;
function MakeInstallEditableCmd: TArray<string>; inline;
function MakeInstallTargetCmd: TArray<string>; inline;
function MakeInstallPlatformCmd: TArray<string>; inline;
function MakeInstallPythonVersionCmd: TArray<string>; inline;
function MakeIntallPythonImplementationCmd: TArray<string>; inline;
function MakeInstallAbiCmd: TArray<string>; inline;
function MakeInstallUserCmd: TArray<string>; inline;
function MakeInstallRootCmd: TArray<string>; inline;
function MakeInstallPrefixCmd: TArray<string>; inline;
function MakeInstallSrcCmd: TArray<string>; inline;
function MakeInstallUpgradeCmd: TArray<string>; inline;
function MakeInstallUpgradeStrategyCmd: TArray<string>; inline;
function MakeInstallForceReinstallCmd: TArray<string>; inline;
function MakeInstallIgnoreInstalledCmd: TArray<string>; inline;
function MakeInstallIgnoreRequiresPythonCmd: TArray<string>; inline;
function MakeInstallNoBuildIsolationCmd: TArray<string>; inline;
function MakeInstallUsePe517Cmd: TArray<string>; inline;
function MakeInstallOptionCmd: TArray<string>; inline;
function MakeInstallGlobalOptionCmd: TArray<string>; inline;
function MakeInstallCompileCmd: TArray<string>; inline;
function MakeInstallNoCompileCmd: TArray<string>; inline;
function MakeInstallNoWarnScriptLocationCmd: TArray<string>; inline;
function MakeInstallNoWarnConflictsCmd: TArray<string>; inline;
function MakeInstallNoBinaryCmd: TArray<string>; inline;
function MakeInstallOnlyBinaryCmd: TArray<string>; inline;
function MakeInstallVerboseCmd: TArray<string>; inline;
function MakeInstallReportCmd: TArray<string>; inline;
function MakeInstallPreferBinaryCmd: TArray<string>; inline;
function MakeInstallRequireHashesCmd: TArray<string>; inline;
function MakeInstallProgressBarCmd: TArray<string>; inline;
function MakeInstallNoCleanCmd: TArray<string>; inline;
function MakeInstallIndexUrlCmd: TArray<string>; inline;
function MakeInstallExtraIndexUrlCmd: TArray<string>; inline;
function MakeInstallNoIndexCmd: TArray<string>; inline;
function MakeInstallFindLinksCmd: TArray<string>; inline;
end;
implementation
constructor TPyPackageManagerCmdPipInstall.Create(
const ADefs: TPyPackageManagerDefsOptsPipInstall);
begin
FOpts := ADefs;
end;
function TPyPackageManagerCmdPipInstall.MakeInstallAbiCmd: TArray<string>;
begin
if not FOpts.Abi.IsEmpty() then
Result := TArray<string>.Create('--abi', FOpts.Abi);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallCompileCmd: TArray<string>;
begin
if FOpts.Compile then
Result := TArray<string>.Create('--compile');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallConstraintCmd: TArray<string>;
begin
if not FOpts.Constraint.IsEmpty() then
Result := TArray<string>.Create('-c', FOpts.Constraint);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallEditableCmd: TArray<string>;
begin
if not FOpts.Editable.IsEmpty() then
Result := TArray<string>.Create('-e', FOpts.Editable);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallExtraIndexUrlCmd: TArray<string>;
begin
if not FOpts.ExtraIndexUrl.IsEmpty() then
Result := TArray<string>.Create('--extra-index-url', FOpts.ExtraIndexUrl);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallFindLinksCmd: TArray<string>;
begin
if not FOpts.FindLinks.IsEmpty() then
Result := TArray<string>.Create('-f', FOpts.FindLinks);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallForceReinstallCmd: TArray<string>;
begin
if FOpts.ForceReinstall then
Result := TArray<string>.Create('--force-reinstall');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallGlobalOptionCmd: TArray<string>;
var
LList: TList<string>;
LStr: string;
begin
LList := TList<string>.Create();
try
if FOpts.GlobalOption.Count > 0 then
for LStr in FOpts.GlobalOption do begin
LList.Add('--global-option');
LList.Add(LStr);
end;
Result := LList.ToArray();
finally
LList.Free();
end;
end;
function TPyPackageManagerCmdPipInstall.MakeInstallIgnoreInstalledCmd: TArray<string>;
begin
if FOpts.IgnoreInstalled then
Result := TArray<string>.Create('-I');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallIgnoreRequiresPythonCmd: TArray<string>;
begin
if FOpts.IgnoreRequiresPython then
Result := TArray<string>.Create('--ignore-requires-python');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallIndexUrlCmd: TArray<string>;
begin
if not FOpts.IndexUrl.IsEmpty() then
Result := TArray<string>.Create('--index-url', FOpts.IndexUrl);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallOptionCmd: TArray<string>;
var
LList: TList<string>;
LStr: string;
begin
LList := TList<string>.Create();
try
if FOpts.InstallOption.Count > 0 then
for LStr in FOpts.InstallOption do begin
LList.Add('--install-option');
LList.Add(LStr);
end;
Result := LList.ToArray();
finally
LList.Free();
end;
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoBinaryCmd: TArray<string>;
begin
if FOpts.NoBinary then
Result := TArray<string>.Create('--no-binary');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoBuildIsolationCmd: TArray<string>;
begin
if FOpts.NoBuildIsolation then
Result := TArray<string>.Create('--no-build-isolation');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoCleanCmd: TArray<string>;
begin
if FOpts.NoClean then
Result := TArray<string>.Create('--no-clean');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoCompileCmd: TArray<string>;
begin
if FOpts.NoCompile then
Result := TArray<string>.Create('--no-compile');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoDepsCmd: TArray<string>;
begin
if FOpts.NoDeps then
Result := TArray<string>.Create('--no-deps');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoIndexCmd: TArray<string>;
begin
if FOpts.NoIndex then
Result := TArray<string>.Create('--no-index');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoWarnConflictsCmd: TArray<string>;
begin
if FOpts.NoWarnConflicts then
Result := TArray<string>.Create('--no-warn-conflicts');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallNoWarnScriptLocationCmd: TArray<string>;
begin
if FOpts.NoWarnScriptLocation then
Result := TArray<string>.Create('--no-warn-script-location');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallOnlyBinaryCmd: TArray<string>;
begin
if not FOpts.OnlyBinary.IsEmpty() then
Result := TArray<string>.Create('--only-binary', FOpts.OnlyBinary);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallVerboseCmd: TArray<string>;
begin
if FOpts.Verbose then
Result := TArray<string>.Create('-v');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallPlatformCmd: TArray<string>;
begin
if not FOpts.Platform.IsEmpty() then
Result := TArray<string>.Create('--platform ', FOpts.Platform);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallReportCmd: TArray<string>;
begin
if not FOpts.Report.IsEmpty() then
Result := TArray<string>.Create('--report ', FOpts.Report);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallPreCmd: TArray<string>;
begin
if FOpts.Pre then
Result := TArray<string>.Create('--pre');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallPreferBinaryCmd: TArray<string>;
begin
if FOpts.PreferBinary then
Result := TArray<string>.Create('--prefer-binary');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallPrefixCmd: TArray<string>;
begin
if not FOpts.Prefix.IsEmpty() then
Result := TArray<string>.Create('--prefix', FOpts.Prefix);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallProgressBarCmd: TArray<string>;
begin
if FOpts.ProgressBar then
Result := TArray<string>.Create('--progress-bar', 'on')
else
Result := TArray<string>.Create('--progress-bar', 'off');
end;
function TPyPackageManagerCmdPipInstall.MakeIntallPythonImplementationCmd: TArray<string>;
begin
if not FOpts.PythonImplementation.IsEmpty() then
Result := TArray<string>.Create('--implementation', FOpts.PythonImplementation);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallPythonVersionCmd: TArray<string>;
begin
if not FOpts.PythonVersion.IsEmpty() then
Result := TArray<string>.Create('--python-version', FOpts.PythonVersion);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallRequireHashesCmd: TArray<string>;
begin
if FOpts.RequireHashes then
Result := TArray<string>.Create('--require-hashes');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallRequirementCmd: TArray<string>;
begin
if not FOpts.Requirement.IsEmpty() then
Result := TArray<string>.Create('-r', FOpts.Requirement);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallRootCmd: TArray<string>;
begin
if not FOpts.Root.IsEmpty() then
Result := TArray<string>.Create('--root', FOpts.Root);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallSrcCmd: TArray<string>;
begin
if not FOpts.Source.IsEmpty() then
Result := TArray<string>.Create('--src', FOpts.Source);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallTargetCmd: TArray<string>;
begin
if not FOpts.Target.IsEmpty() then
Result := TArray<string>.Create('-t ', FOpts.Target);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallUpgradeCmd: TArray<string>;
begin
if FOpts.Upgrade then
Result := TArray<string>.Create('-U');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallUpgradeStrategyCmd: TArray<string>;
begin
if not FOpts.UpgradeStrategy.IsEmpty() then
Result := TArray<string>.Create('--upgrade-strategy', FOpts.UpgradeStrategy);
end;
function TPyPackageManagerCmdPipInstall.MakeInstallUsePe517Cmd: TArray<string>;
begin
if FOpts.UsePep517 then
Result := TArray<string>.Create('--use-pep517');
end;
function TPyPackageManagerCmdPipInstall.MakeInstallUserCmd: TArray<string>;
begin
if FOpts.User then
Result := TArray<string>.Create('--user');
end;
end.