Question
Rabobank
NL
Last activity: 6 Jul 2018 3:42 EDT
Does the Pega Platform support any native capability for running Python code in Pega?
We are investigating the possibility of running Python code natively in Pega. We are not aware of any such capability but perhaps someone could share some insights on this.
We have already investigated the possibility of using Jython java libraries and running the python code, but this does not look to be the best solution.
Any comments will be welcome!!!
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
GB
Python (like Java and .NET) compiles to Byte-Code and runs on a Virtual Machine (a 'PVM').
(The analogy for PVM for Java is 'JVM', and for .NET 'CLR').
PRPC does not ship with a 'PVM' (nor a .NET clr for that matter) ; and therefore cannot run Python 'natively'. (nor .Net 'natively').
PRPC is a Java Platform.
Strictly speaking - it doesn't run 'CPython', but as you point out - you *can* compile Python to *JAVA* bytecode - using Jython; and then the JVM is able to run this.
You can do this for sure; but the 'Jython' JAR(s?) does NOT ship by default with PRPC .
In fact you can run Clojure, Javascript, Scala and other Languages; so long as they support compiling to JVM byte-code.
I just double-checked that there is no JYTHON jars shipped with PRPC731 by running this:
select * from pr_engineclasses
where lower(pzjar) like '%jython%';
(no rows found).
Instellars
IN
Hi,
I am not sure about running a python script in Pega but you can make use of Pega APIs by calling them from a python script. See if this helps you:
https://community.pega.com/knowledgebase/articles/getting-started-pega-api
Rabobank
NL
Thanks for the reply.
The possibility of calling Pega API's or even Custom Service REST is always there, but then python would have to make the API requests. This is something that we are trying to avoid.
Rabobank
NL
Any ideas anyone ?
Accepted Solution
Pegasystems Inc.
GB
Python (like Java and .NET) compiles to Byte-Code and runs on a Virtual Machine (a 'PVM').
(The analogy for PVM for Java is 'JVM', and for .NET 'CLR').
PRPC does not ship with a 'PVM' (nor a .NET clr for that matter) ; and therefore cannot run Python 'natively'. (nor .Net 'natively').
PRPC is a Java Platform.
Strictly speaking - it doesn't run 'CPython', but as you point out - you *can* compile Python to *JAVA* bytecode - using Jython; and then the JVM is able to run this.
You can do this for sure; but the 'Jython' JAR(s?) does NOT ship by default with PRPC .
In fact you can run Clojure, Javascript, Scala and other Languages; so long as they support compiling to JVM byte-code.
I just double-checked that there is no JYTHON jars shipped with PRPC731 by running this:
select * from pr_engineclasses
where lower(pzjar) like '%jython%';
(no rows found).
-
Raju Botu
Rabobank
NL
Hi
Thanks for the reply. This is very helpful.
Pegasystems Inc.
GB
No worries; so another thing with Python - unlike Java (in the main) CPython is a lot more welcoming when it comes to interacting with or wrapping 'C' libraries (analogous to 'JNI' in Java).....libraries built in this way will *only* run on CPython ; you cannot use them in Jython. (Or IronPython - which runs on the .NET CLR).
So if your interest in using Python from PRPC was to make use of some existing library or API - you might still be able to use it (Via Jython) - so long as it a pure Python Library.