Skip to content

Commit 11b25a3

Browse files
committed
demo_console: detect macOS lib name
1 parent 35286bd commit 11b25a3

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

demos_lazarus/Python_Console/formmain.pas

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ implementation
4242
{$R *.lfm}
4343

4444
const
45-
cPyLibraryWindows = 'python37.dll';
46-
cPyLibraryLinux = 'libpython3.8.so.1.0'; //default in Ubuntu 20.x
47-
cPyLibraryMac = '/Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib';
48-
cPyZipWindows = 'python37.zip';
45+
cPyLibraryWindows: string = 'python37.dll';
46+
cPyLibraryLinux: string = 'libpython3.8.so.1.0'; //default in Ubuntu 20.x
47+
cPyLibraryMac: string = '/Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib';
48+
cPyZipWindows: string = 'python37.zip';
4949

5050
function Py_s0(Self, Args : PPyObject): PPyObject; cdecl;
5151
begin
@@ -145,5 +145,30 @@ procedure TfmMain.DoPy_InitEngine;
145145
PythonEngine.LoadDll;
146146
end;
147147

148+
{$ifdef darwin}
149+
procedure InitMacLibPath;
150+
var
151+
N: integer;
152+
S: string;
153+
begin
154+
for N:= 5 to 10 do
155+
begin
156+
S:= Format('/Library/Frameworks/Python.framework/Versions/3.%d/lib/libpython3.%d.dylib',
157+
[N, N]);
158+
if FileExists(S) then
159+
begin
160+
cPyLibraryMac:= S;
161+
exit;
162+
end;
163+
end;
164+
end;
165+
{$endif}
166+
167+
initialization
168+
169+
{$ifdef darwin}
170+
InitMacLibPath;
171+
{$endif}
172+
148173
end.
149174

0 commit comments

Comments
 (0)