@@ -127,7 +127,7 @@ TScanner = class(TPersistent)
127
127
FEnvironmentPath: string;
128
128
FDeleteEmbeddable: boolean;
129
129
public
130
- procedure Scan (ACallback: TProc<TPythonVersionProp, string>);
130
+ procedure Scan (const AEmbedabblesPath: string; ACallback: TProc<TPythonVersionProp, string>);
131
131
published
132
132
property AutoScan: boolean read FAutoScan write FAutoScan default false;
133
133
property ScanRule: TScanRule read FScanRule write FScanRule;
@@ -207,6 +207,7 @@ function TPyCustomEmbeddableDistribution.FileIsExecutable(
207
207
const AFilePath: string): boolean;
208
208
begin
209
209
{ $WARN SYMBOL_PLATFORM OFF}
210
+ // Avoiding symlinks
210
211
Result := (TFileAttribute.faOwnerExecute in TFile.GetAttributes(AFilePath))
211
212
or (TFileAttribute.faGroupExecute in TFile.GetAttributes(AFilePath))
212
213
or (TFileAttribute.faOthersExecute in TFile.GetAttributes(AFilePath));
@@ -233,15 +234,6 @@ function TPyCustomEmbeddableDistribution.FindExecutable: string;
233
234
if (TPath.GetFileName(LFile) = ' python' + PythonVersion) and (FileIsExecutable(LFile)) then
234
235
Exit(TArray<string>.Create(LFile));
235
236
end ;
236
-
237
- { $WARN SYMBOL_PLATFORM OFF}
238
- LFile := Result[High(Result)];
239
- if (TFileAttribute.faOwnerExecute in TFile.GetAttributes(LFile))
240
- or (TFileAttribute.faGroupExecute in TFile.GetAttributes(LFile))
241
- or (TFileAttribute.faOthersExecute in TFile.GetAttributes(LFile)) then // Avoiding symlinks
242
- Exit(TArray<string>.Create(LFile));
243
- { $WARN SYMBOL_PLATFORM ON}
244
-
245
237
{ $ENDIF POSIX}
246
238
end ;
247
239
{ $IFNDEF MSWINDOWS}
@@ -252,25 +244,25 @@ function TPyCustomEmbeddableDistribution.FindExecutable: string;
252
244
{ $IFDEF MSWINDOWS}
253
245
Result := TPath.Combine(GetEnvironmentPath(), ' python.exe' );
254
246
if not TFile.Exists(Result) then
255
- Result := String.Empty;
247
+ Exit( String.Empty) ;
256
248
{ $ELSEIF DEFINED(ANDROID)}
249
+ // Let's try it in the library path first - we should place it in the library path in Android
257
250
Result := TPath.GetLibraryPath();
258
251
LFiles := DoSearch(Result);
259
252
if LFiles <> nil then
260
253
Exit(LFiles[Low(LFiles)]);
261
254
Result := TPath.Combine(GetEnvironmentPath(), ' bin' );
262
255
{ $ELSE}
263
256
Result := TPath.Combine(GetEnvironmentPath(), ' bin' );
257
+ { $ENDIF}
264
258
265
259
LFiles := DoSearch(Result);
266
-
267
260
if Length(LFiles) > 0 then begin
268
261
Result := LFiles[Low(LFiles)];
269
262
if not TFile.Exists(Result) then
270
263
Result := String.Empty;
271
264
end else
272
265
Result := String.Empty;
273
- { $ENDIF}
274
266
end ;
275
267
276
268
function TPyCustomEmbeddableDistribution.FindSharedLibrary : string;
@@ -306,11 +298,13 @@ function TPyCustomEmbeddableDistribution.FindSharedLibrary: string;
306
298
{ $IFDEF MSWINDOWS}
307
299
LPath := GetEnvironmentPath();
308
300
{ $ELSEIF DEFINED(ANDROID)}
301
+ // Let's try it in the library path first - we should place it in the library path in Android
309
302
LPath := TPath.GetLibraryPath();
310
303
LFiles := DoSearch(LLibName, LPath);
311
304
if LFiles <> nil then
312
305
Exit(LFiles[Low(LFiles)]);
313
- LPath := GetEnvironmentPath();
306
+ // Try to find it in the environments path
307
+ LPath := TPath.Combine(GetEnvironmentPath(), ' lib' );
314
308
{ $ELSE}
315
309
LPath := TPath.Combine(GetEnvironmentPath(), ' lib' );
316
310
{ $ENDIF}
@@ -406,12 +400,13 @@ procedure TPyEmbeddedEnvironment.Prepare;
406
400
if FScanner.AutoScan then begin
407
401
if PythonProject.Enabled then
408
402
if FScanner.EmbeddablesPath.IsEmpty() then begin
409
- FScanner.EmbeddablesPath := TPyEnvironmentPath.ResolvePath(TPyEnvironmentPath. DEPLOY_PATH) ;
403
+ FScanner.EmbeddablesPath := TPyEnvironmentPath.DEPLOY_PATH;
410
404
FScanner.ScanRule := TScanRule.srFileName;
411
405
FScanner.DeleteEmbeddable := true;
412
406
end ;
413
407
414
408
FScanner.Scan(
409
+ TPyEnvironmentPath.ResolvePath(FScanner.EmbeddablesPath),
415
410
procedure(APyVersionInfo: TPythonVersionProp; AEmbeddablePackage: string) begin
416
411
if Assigned(Distributions.LocateEnvironment(APyVersionInfo.RegVersion)) then
417
412
Exit;
@@ -441,7 +436,7 @@ procedure TPyEmbeddedEnvironment.SetScanner(const Value: TScanner);
441
436
442
437
{ TPyEmbeddedEnvironment.TScanner }
443
438
444
- procedure TPyEmbeddedEnvironment.TScanner .Scan(
439
+ procedure TPyEmbeddedEnvironment.TScanner .Scan(const AEmbedabblesPath: string;
445
440
ACallback: TProc<TPythonVersionProp, string>);
446
441
var
447
442
I: Integer;
@@ -453,14 +448,14 @@ procedure TPyEmbeddedEnvironment.TScanner.Scan(
453
448
if not Assigned(ACallback) then
454
449
Exit;
455
450
456
- if not TDirectory.Exists(FEmbeddablesPath ) then
451
+ if not TDirectory.Exists(AEmbedabblesPath ) then
457
452
raise Exception.Create(' Directory not found.' );
458
453
459
454
// Look for version named subfolders
460
455
if (FScanRule = TScanRule.srFolder) then begin
461
456
LSearchPatter := ' *.zip' ;
462
457
for I := Low(PYTHON_KNOWN_VERSIONS) to High(PYTHON_KNOWN_VERSIONS) do begin
463
- LPath := TPath.Combine(FEmbeddablesPath , PYTHON_KNOWN_VERSIONS[I].RegVersion);
458
+ LPath := TPath.Combine(AEmbedabblesPath , PYTHON_KNOWN_VERSIONS[I].RegVersion);
464
459
if not TDirectory.Exists(LPath) then
465
460
Continue;
466
461
@@ -475,7 +470,7 @@ procedure TPyEmbeddedEnvironment.TScanner.Scan(
475
470
for I := Low(PYTHON_KNOWN_VERSIONS) to High(PYTHON_KNOWN_VERSIONS) do begin
476
471
LPythonVersion := PYTHON_KNOWN_VERSIONS[I].RegVersion;
477
472
LSearchPatter := Format(' python3-*-%s*.zip' , [LPythonVersion]);
478
- LFiles := TDirectory.GetFiles(FEmbeddablesPath , LSearchPatter, TSearchOption.soTopDirectoryOnly);
473
+ LFiles := TDirectory.GetFiles(AEmbedabblesPath , LSearchPatter, TSearchOption.soTopDirectoryOnly);
479
474
if (Length(LFiles) = 0 ) then
480
475
Continue;
481
476
0 commit comments