Embarcadero / PythonEnvironments

Components to simplify the deployment for Python environments for Delphi applications using Python4Delphi.
MIT License
41 stars 15 forks source link

Delphi 11 Only? #31

Open peardox opened 2 years ago

peardox commented 2 years ago

It looks like you've used some Delphi 11 specific feature in Tools

Compiling under 10.4.1 (I was testing) or 10.4.2 fully patched (switched when 10.4.1 didn't work) this happens...

Checking project dependencies... Building P4DTools.dproj (Release, Win32) brcc32 command line for "P4DTools.vrc" d:\program files (x86)\embarcadero\studio\21.0\bin\cgrc.exe -c65001 P4DTools.vrc -foP4DTools.res dcc32 command line for "P4DTools.dpk" d:\program files (x86)\embarcadero\studio\21.0\bin\dcc32.exe -$D0 -$L- -$Y- --no-config -B -Q -TX.bpl -AGenerics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows; DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DRELEASE -E.\Win32\Release -I"d:\program files (x86)\embarcadero\studio\21.0\lib\Win32\release"; C:\Users\simon\Documents\Embarcadero\Studio\21.0\Imports;"d:\program files (x86)\embarcadero\studio\21.0\Imports"; C:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp;"d:\program files (x86)\embarcadero\studio\21.0\include"; D:\Delphi\10.4.2\P4DSuite\Lightweight-Python-Wrappers\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\P4D-Data-Sciences\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\src\AddOn;D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonPackages4Delphi\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\python4delphi\lib\Win32\Release -LEC:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl -LNC:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp -NU..\lib\Win32\Release -NSWinapi; System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap; -O"d:\program files (x86)\embarcadero\studio\21.0\lib\Win32\release";C:\Users\simon\Documents\Embarcadero\Studio\21.0\Imports;"d:\program files (x86)\embarcadero\studio\21.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp;"d:\program files (x86)\embarcadero\studio\21.0\include"; D:\Delphi\10.4.2\P4DSuite\Lightweight-Python-Wrappers\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\P4D-Data-Sciences\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\src\AddOn;D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonPackages4Delphi\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\python4delphi\lib\Win32\Release -R..\resources; "d:\program files (x86)\embarcadero\studio\21.0\lib\Win32\release";C:\Users\simon\Documents\Embarcadero\Studio\21.0\Imports;"d:\program files (x86)\embarcadero\studio\21.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp;"d:\program files (x86)\embarcadero\studio\21.0\include"; D:\Delphi\10.4.2\P4DSuite\Lightweight-Python-Wrappers\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\P4D-Data-Sciences\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\src\AddOn;D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonPackages4Delphi\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\python4delphi\lib\Win32\Release -U"d:\program files (x86)\embarcadero\studio\21.0\lib\Win32\release";C:\Users\simon\Documents\Embarcadero\Studio\21.0\Imports;"d:\program files (x86)\embarcadero\studio\21.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp;"d:\program files (x86)\embarcadero\studio\21.0\include"; D:\Delphi\10.4.2\P4DSuite\Lightweight-Python-Wrappers\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\P4D-Data-Sciences\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\src\AddOn;D:\Delphi\10.4.2\P4DSuite\PythonEnviroments\lib\Win32\Release; D:\Delphi\10.4.2\P4DSuite\PythonPackages4Delphi\lib\Win32\Release;D:\Delphi\10.4.2\P4DSuite\python4delphi\lib\Win32\Release -JL -NBC:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp -NHC:\Users\Public\Documents\Embarcadero\Studio\21.0\hpp\Win32 -NOC:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp P4DTools.dpk
[dcc32 Error] PyTools.Notification.Channel.pas(282): E2003 Undeclared identifier: 'GetAttribute' [dcc32 Error] PyTools.Notification.Channel.pas(282): E2029 Expression expected but ')' found [dcc32 Warning] PyTools.Notification.Channel.pas(282): W1023 Comparing signed and unsigned types - widened both operands [dcc32 Error] PyTools.Notification.Channel.pas(283): E2008 Incompatible types [dcc32 Error] PyTools.Notification.Channel.pas(284): E2003 Undeclared identifier: 'ChannelType' [dcc32 Error] PyTools.Notification.Channel.pas(307): E2003 Undeclared identifier: 'GetAttribute' [dcc32 Error] PyTools.Notification.Channel.pas(307): E2029 Expression expected but ')' found [dcc32 Warning] PyTools.Notification.Channel.pas(307): W1023 Comparing signed and unsigned types - widened both operands [dcc32 Error] PyTools.Notification.Channel.pas(308): E2008 Incompatible types [dcc32 Error] PyTools.Notification.Channel.pas(309): E2003 Undeclared identifier: 'Identifier' [dcc32 Error] PyTools.Notification.Channel.pas(382): E2003 Undeclared identifier: 'GetAttribute' [dcc32 Error] PyTools.Notification.Channel.pas(382): E2029 Expression expected but ')' found [dcc32 Warning] PyTools.Notification.Channel.pas(382): W1023 Comparing signed and unsigned types - widened both operands [dcc32 Error] PyTools.Notification.Channel.pas(383): E2008 Incompatible types [dcc32 Error] PyTools.Notification.Channel.pas(384): E2003 Undeclared identifier: 'EventType' [dcc32 Fatal Error] PyTools.Notification.pas(36): F2063 Could not compile used unit 'PyTools.Notification.Channel.pas' Failed Elapsed time: 00:00:00.3

peardox commented 2 years ago

Found out why it's broken (D11 enhancement)

PyTools.Notification.Channel.pas

class function TNotificationChannel.GetNotificationChannelType: TNotificationChannelIdentifier; e.g.

while Assigned(LRttiType) do begin var LAttribute := LRttiType.GetAttribute\<ChannelTypeAttribute>(); if Assigned(LAttribute) then Exit(LAttribute.ChannelType);

TRttiType.GetAttribute is only in D11 while TRttiType.GetAttributes (plural) is in all the versions I've looked up

The TRttiType.GetAttribute version is used three times in this source file

lmbelo commented 2 years ago

Found out why it's broken (D11 enhancement)

PyTools.Notification.Channel.pas

class function TNotificationChannel.GetNotificationChannelType: TNotificationChannelIdentifier; e.g.

while Assigned(LRttiType) do begin var LAttribute := LRttiType.GetAttribute(); if Assigned(LAttribute) then Exit(LAttribute.ChannelType);

TRttiType.GetAttribute is only in D11 while TRttiType.GetAttributes (plural) is in all the versions I've looked up

The TRttiType.GetAttribute version is used three times in this source file

Nice catch. Fixing that.

peardox commented 2 years ago

Let me know when I can test it on 10.4.2 - I've got a load of VMs set up for testing

lmbelo commented 2 years ago

Let me know when I can test it on 10.4.2 - I've got a load of VMs set up for testing

Fixing it right away.

lmbelo commented 2 years ago

Try it out 89e5d54436c3a8d9b5fc169f17a7910553b63c73

peardox commented 2 years ago

Will do shortly (dinner)

peardox commented 2 years ago

Nope - TCustomAttributeClass is Alexandria only as well

It compiles OK though if you wrap the helper in an ifdef and add the type declaration

Add 3 lines and its OK. Note the ifdef ver340 is OK for this version as < 340 doesn't have libsuffix auto so won't work anyway

{$IFDEF VER340} type //For backward compatibility TCustomAttributeClass = class of TCustomAttribute;

TRttiObjectHelper = class helper for TRttiObject public function GetAttribute(AAttrClass: TCustomAttributeClass): TCustomAttribute; overload; function GetAttribute: T; overload; inline; end;

{ TRttiObjectHelper }

function TRttiObjectHelper.GetAttribute( AAttrClass: TCustomAttributeClass): TCustomAttribute; var LAttr: TCustomAttribute; begin for LAttr in GetAttributes do if LAttr is AAttrClass then Exit(LAttr); Result := nil; end;

function TRttiObjectHelper.GetAttribute: T; begin Result := T(GetAttribute(T)); end; {$ENDIF}

lmbelo commented 2 years ago

Sorry, I missed the custom attribute meta class.

peardox commented 2 years ago

I'm just running a full check against a branch with the fix stated above.

I want to do full installations and test against 10.4 + 11.2 (it'll take a while)

Is there a demo that uses the cancel notification for Win, Mac + Linux?

I notice there's a new build of pythonengine as well (hence full test). The new FMXLinux package for python4delphi has some compontns in it - I take it those don't want installing, just building (I'll check anyway)?

lmbelo commented 2 years ago

The FMXLinux package is Linux intended only. Once you have the design-time packages installed on the IDE, you only need to build the run-time components on each platform.

lmbelo commented 2 years ago

The meta class is fixed, BTW.

peardox commented 2 years ago

I noticed - prefer it with an ifdef ver340 wrapping it so the code is only present in 10.4 though

Internet is being really bad today - dropping all the time. Got the new stuff now though so about to test on 11.2 and 10.4

peardox commented 2 years ago

The Linux version of python4delphi is broken. It has Windows as the default (it's Linux only).

PythonFmx does not have Linux as a target - it creates PythonGUIInputOutput - and has fmx and bindcomp as requirements (will compile if wrapped in a ifndef linux).

PythonFmxLinux has fmx as a requirement - again ifndef linux gets around this to make it compile

There is no redist in fmxlinux-1.65 (included with 10.4) so the only possibility is a lot of implicit binding there. 11.2 has fmxlinux-1.71 which includes the redist - no implicit if in path - used as a bpl replacement I guess

lmbelo commented 2 years ago

The Delphi IDE includes Win32 automatically.

I don't understand. How hard is to set the active platform? It only requires a single click!

Screenshot 2022-11-16 at 12 39 05

Again, including compilation directives in a .dpr file won't work out.

Am I mad or the GUI IO is included in the Linux package?

Screenshot 2022-11-16 at 12 40 23

peardox commented 2 years ago

1) won't work as PythonFMX is currently set to output a .dpr rather than a .so 2) It ifdef doesn't go in the the .dpr, it goes in the .dproj where it's fine 3) Doesn't actually produce the output for Linux because of (2) so Linix project compilation including a GUIInputOutput will fail

If you build a simpe Linux app with a GUIInputOutput it won't run (never has without the above mods)

lmbelo commented 2 years ago

1) OMG why are you compiling PythonFMX? You MUST compile the PythonFMXLinux for LINUX. It is Linux only! Why are you compiling the PythonFMX? It doesn't have Linux enabled. We have talked about it and all the clarification were given.

2) IFDEF in the .dproj? That is new.

3) Invalid.

peardox commented 2 years ago

Ahh - the problem is that the Linux project has a load of stuff in it it shouldn't have (like VCL etc)

Shouldn't it look more like this?

image

Noting the Win32 install includes the design-time stuff?

peardox commented 2 years ago

I'm now testing 11.2 + doing it your way to see if GUI works...

lmbelo commented 2 years ago

The Python package isn't GUI dependent, It shall compile to every platform :D

The VCL one is only intended for Win32 and Win64.

The FMX one is intended to every platform that has FMX GUI natively distributed.

The FMXLinux one is Linux FMX GUI only.

lmbelo commented 2 years ago

I'm now testing 11.2 + doing it your way to see if GUI works...

I bet you will get it working out.

peardox commented 2 years ago

10.4.2 all went fine and 11.2 is going well so looks like this issue will be closed shortly

peardox commented 2 years ago

Everything apart from Linux checks out (didn't do Max ARM though - I'd have to rent a Mac)

Linux gives me ... [DCC Fatal Error] Unit1.pas(16): F2051 Unit PyCommon was compiled with a different version of PythonEngine.TPythonEngine

lmbelo commented 2 years ago

You are targeting two different compilations of the same unit. Check your environment out.

This one you will figure out by yourself.