[
https://issues.apache.org/jira/browse/CAMEL-24337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-24337 started by Ramu.
------------------------------------
> Support Python 3
> ----------------
>
> Key: CAMEL-24337
> URL: https://issues.apache.org/jira/browse/CAMEL-24337
> Project: Camel
> Issue Type: New Feature
> Affects Versions: 4.21.0
> Reporter: Raymond
> Assignee: Ramu
> Priority: Major
>
> As based on [this Zulip
> topic|https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/Modernize.20camel-python.20with.20GraalPy.20for.20Python.203.20Support/with/614304103]
> *Modernize camel-python with GraalPy for Python 3 Support*
> The current {{camel-python}} component is based on Jython, which restricts
> execution strictly to Python 2.7. Given that Python 2 reached end-of-life
> years ago, this component is increasingly difficult to use in modern
> environments.
> A similar situation occurred with {{camel-javascript}} when Rhino and Nashorn
> were phased out. That component was successfully updated to leverage
> GraalVM's JavaScript engine ({{{}org.graalvm.js{}}}).
> GraalVM now offers *GraalPy* ({{{}org.graalvm.python:python-language{}}}), a
> full Python 3 runtime for the JVM built on Truffle.
> *Rationale*
> * *Python 3 Compatibility:* Allows Camel users to execute modern Python 3
> syntax and standard libraries within routes.
> * *Consistency Across Scripting Components:* Standardizes Camel's polyglot
> ecosystem around GraalVM engines alongside {{{}camel-javascript{}}}.
> * *Polyglot Interoperability:* Uses {{org.graalvm.polyglot.Context}} to pass
> {{Exchange}} bodies, headers, and properties directly between Java and Python.
> * *Sandboxing:* GraalVM allows a [Sandboxing
> policy.|https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/Modernize.20camel-python.20with.20GraalPy.20for.20Python.203.20Support/with/614304103]
>
> h3. Implementation
> Update or replace the underlying execution engine of {{camel-python}} to use
> the GraalVM Polyglot API ({{{}org.graalvm.polyglot.Context{}}}) rather than
> the legacy {{javax.script}} JSR-223 / Jython implementation.
> I was just running Python on Graal (independently of Camel), and then thought
> might be something to look into for Camel as well.
> *Relevant Links*
> [https://www.graalvm.org/jdk24/reference-manual/python/]
> [https://mvnrepository.com/artifact/org.graalvm.python]
> [https://www.graalvm.org/latest/security-guide/sandboxing/]
> *Sandboxing*
> As Python is really powerful it can also be vulnrable, especially when
> third-parties use it. GraalVM (Through the truffleVM) allows a SandboxPolicy:
> * Trusted
> * Constrained
> * Isolated
> * Untrusted
> To be secure by default, probably it would be good to put it on "Constrained"
> as default.
> *Note*
> A downside of GraalPy, contrary to GraalJS is that it's relative big. The
> main dependency:
> [https://mvnrepository.com/artifact/org.graalvm.python/python]
> Contains both python language runtime (90 mb), standard library (13 mb), and
> trufflevm (1 mb). I guess that's what most would like, but it maybe good to
> notify this in the documentation.
> It's around double that of the current Python based on Jython (which is
> around 50 mb)
> *Note 2*
> Another thing to consider if this will replace the current camel-python, or
> create a new one camel-python3. I don't use the current component especially
> because it's based on Python 2, but this maybe relevant to current users (to
> at least be clear in the documentation about it).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)