@@ -3033,7 +3033,9 @@ function TDynamicDll.GetDllPath : string;
3033
3033
3034
3034
if (DLLPath = ' ' ) and not FInExtensionModule then begin
3035
3035
{ $IFDEF MSWINDOWS}
3036
- IsPythonVersionRegistered(RegVersion, Result, AllUserInstall);
3036
+ if IsPythonVersionRegistered(RegVersion, Result, AllUserInstall) and (Self is TPythonEngine) then
3037
+ // https://github.com/python/cpython/issues/100171
3038
+ TPythonEngine(Self).SetPythonHome(Result);
3037
3039
{ $ENDIF}
3038
3040
{ $IFDEF DARWIN}
3039
3041
Result := ' /Library/Frameworks/Python.framework/Versions/' + RegVersion + ' /lib/' ;
@@ -4466,7 +4468,6 @@ procedure TPythonEngine.Initialize;
4466
4468
4467
4469
var
4468
4470
i : Integer;
4469
- WorkAround: AnsiString;
4470
4471
begin
4471
4472
if Assigned(gPythonEngine) then
4472
4473
raise Exception.Create(' There is already one instance of TPythonEngine running' );
@@ -4505,24 +4506,6 @@ procedure TPythonEngine.Initialize;
4505
4506
if not Initialized then
4506
4507
Initialize;
4507
4508
4508
- // WorkAround for https://github.com/python/cpython/issues/100171
4509
- if (MajorVersion = 3 ) and (MinorVersion >= 11 ) then
4510
- begin
4511
- WorkAround :=
4512
- ' import sys' #13 #10 + // 0
4513
- ' if sys.version_info > (3,11,0):' #13 #10 + // 1
4514
- ' import os' #13 #10 + // 2
4515
- ' ' #13 #10 + // 3
4516
- ' dllpath = os.path.join(sys.base_prefix, '' DLLs'' )' #13 #10 + // 4
4517
- ' if dllpath not in sys.path:' #13 #10 + // 5
4518
- ' sys.path.insert(3, dllpath)' #13 #10 + // 6
4519
- ' ' #13 #10 + // 7
4520
- ' del dllpath' #13 #10 + // 8
4521
- ' del os' #13 #10 + // 9
4522
- ' del sys' #13 #10 ; // 10
4523
- ExecString(WorkAround);
4524
- end ;
4525
-
4526
4509
if InitScript.Count > 0 then
4527
4510
ExecStrings(InitScript);
4528
4511
if Assigned(FOnAfterInit) then
0 commit comments