user1769184
user1769184

Reputation: 1621

Find correct python4delphi Tpythonengine parameters

while using Tpythonengine from here python 4 delphi I fail to get my code *.exe running on a different system, due to differences in the python config on these computers. Following the idea of sample code initial idea I completed the way of setting all the python4delphi- TpythonEngine parameters completely through an *.ini file.

There is only a tutorial for setting up python4Delphi on WINDOWS OS ( CONFIG UNDER WINDOWS but not for LINUX.

Can someone help on providing correct parameters for latest UBUNTU, CENTOS, LINUX MX distributions.

the most important code part comes here

    FPythonEngine := TPythonEngine.Create(nil);
      FPythonDelphiVar := TPythonDelphiVar.Create(nil);
      try
        FPythonEngineConfig.SetPythonengineValues(FPythonEngine);
        FPythonEngine.IO := PythonGUIInputOutput;
        FPythonDelphiVar.VarName := 'Properties';
        FPythonDelphiVar.Module := '__main__';
        FPythonDelphiVar.OnExtGetData := PropertiesExtGetData;
        FPythonDelphiVar.OnExtSetData := PropertiesExtSetData;
        FPythonDelphiVar.OnChange := PropertiesChange;
        FPythonDelphiVar.Engine := FPythonEngine;
        FPythonEngine.Loaddll;



and  the transfer of the in ini -file parameters  to the Tpythonengine 

procedure TPythonEngineConfig.SetPythonengineValues(PythonEngine
  : TPythonEngine);
var
  FPyVersions: TPythonVersions;
begin
  ///
  /// convert this  https://github.com/pyscripter/python4delphi/wiki/FindingPython
  /// into a small  automatic setting  of parameter
  ///
  PythonEngine.UseLastKnownVersion := Self.UseLastKnownVersion;
  if Self.UseLastKnownVersion then
  begin
{$IFDEF  MSWINDOWS}
    FPyVersions := GetRegisteredPythonVersions;
    FPyVersions[0].AssignTo(PythonEngine);
{$ENDIF}
{$IFDEF  LINUX}
    ///  not supported on LINUX
    ///  https://en.delphipraxis.net/topic/4700-getregisteredpythonversions-for-linux/
{$ENDIF}
  end
  else
  begin
    PythonEngine.APIVersion := self.APIVersion ;
    PythonEngine.DllName := Self.DllName;
    PythonEngine.DllPath := Self.DllPath;
    PythonEngine.AutoFinalize := Self.AutoFinalize;
    PythonEngine.AutoLoad := Self.AutoLoad;
    PythonEngine.AutoUnload := Self.AutoUnload;
    PythonEngine.RedirectIO := Self.RedirectIO;
    PythonEngine.UseWindowsConsole := Self.UseWindowsConsole;
    PythonEngine.RegVersion := Self.RegVersion;
  end;
end;

Upvotes: 1

Views: 525

Answers (0)

Related Questions