Skip to content

Commit 1ed6e46

Browse files
authored
Merge pull request #63 from talos-gis/Branch_Detect_Python_RegVersion
Detect Python RegVersion correctly for UseLastKnownVersion=False
2 parents ca259a5 + 27563a4 commit 1ed6e46

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3149,6 +3149,7 @@ procedure PyObjectDestructor( pSelf : PPyObject); cdecl;
31493149
procedure FreeSubtypeInst(ob:PPyObject); cdecl;
31503150
procedure Register;
31513151
function PyType_HasFeature(AType : PPyTypeObject; AFlag : Integer) : Boolean;
3152+
function GetPythonVersionFromDLLName(const DLLFileName : String): String;
31523153

31533154
{ Helper functions}
31543155
(*
@@ -4746,7 +4747,9 @@ procedure TPythonEngine.DoOpenDll(const aDllName : String);
47464747
end;
47474748
if not PYTHON_KNOWN_VERSIONS[i].CanUseLatest then
47484749
Break;
4749-
end;
4750+
end
4751+
else
4752+
RegVersion := GetPythonVersionFromDLLName(aDllName);
47504753
inherited;
47514754
end;
47524755

@@ -9754,6 +9757,11 @@ procedure Register;
97549757
TPythonType, TPythonModule, TPythonDelphiVar]);
97559758
end;
97569759

9760+
function GetPythonVersionFromDLLName(const DLLFileName : String): String;
9761+
begin
9762+
Result := DLLFileName[{$IFDEF MSWINDOWS}7{$ELSE}10{$ENDIF}] + '.' + DLLFileName[{$IFDEF MSWINDOWS}8{$ELSE}11{$ENDIF}];
9763+
end;
9764+
97579765
function PyType_HasFeature(AType : PPyTypeObject; AFlag : Integer) : Boolean;
97589766
begin
97599767
//(((t)->tp_flags & (f)) != 0)

PythonForDelphi/Components/Sources/Core/PythonVersions.pas

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ function PythonVersionFromPath(const Path: string; out PythonVersion: TPythonVer
464464
end;
465465
PythonVersion.DLLPath := DLLPath;
466466

467-
SysVersion := Copy(DLLFileName, 7, 2);
468-
Insert('.', SysVersion, 2);
467+
SysVersion := GetPythonVersionFromDLLName(DLLFileName);
469468

470469
PythonVersion.SysVersion := SysVersion;
471470
PythonVersion.fSysArchitecture := PythonVersion.ExpectedArchitecture;

0 commit comments

Comments
 (0)