@@ -3033,7 +3033,9 @@ function  TDynamicDll.GetDllPath : string;
30333033
30343034  if  (DLLPath = ' ' and  not  FInExtensionModule then  begin 
30353035    { $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);
30373039    { $ENDIF} 
30383040    { $IFDEF DARWIN} 
30393041    Result := ' /Library/Frameworks/Python.framework/Versions/' ' /lib/' 
@@ -4466,7 +4468,6 @@ procedure TPythonEngine.Initialize;
44664468
44674469var 
44684470  i : Integer;
4469-   WorkAround: AnsiString;
44704471begin 
44714472  if  Assigned(gPythonEngine) then 
44724473    raise Exception.Create(' There is already one instance of TPythonEngine running' 
@@ -4505,24 +4506,6 @@ procedure TPythonEngine.Initialize;
45054506      if  not  Initialized then 
45064507        Initialize;
45074508
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- 
45264509  if  InitScript.Count > 0  then 
45274510    ExecStrings(InitScript);
45284511  if  Assigned(FOnAfterInit) then 
0 commit comments