1

I recently created a pyDev project and ran the code. It works fine.

Unlike a java or a mule based project, I am unable to find an option to export the pyDev python project I already have in my Anypoint Studio workspace.

I could clearly see that the python interpreter files are already added to my python project. I wished if I could somehow add this to a Mule or Java based project, either as a library(exe, jar) in the build path, or add as a maven dependency(any possible way). The same way how we all used to add a java project into a mule project, or a mule project into a mule project using the above methods(or any).

In the below Image, I have two projects, one is encryption which is a mule based project, and the mule-python which is a pyDev python based project.

My aim is to use the latter in the former (i.e. To make an United Mule Project which runs python too).

I need some assistance from someone who already tried doing this in the past. Any advice from others who haven't tried is also grateful. Thanks in advance.

enter image description here

Thinker-101
  • 554
  • 5
  • 19

2 Answers2

1

You can not integrate a Mule project with a Python project in Eclipse because they are implemented by different Eclipse plugins and they are completely independant. That's the same reason that you can not integrate for example a C++ project with a Java project.

One alternative is that Mule has a Scripting Module that allows to execute Python scripts inside the Mule project using a Java Python implementation (jython). This has limitations (no support for native libraries, no support for pip) but it should be good to run simple scripts like the one in the screenshot.

aled
  • 21,330
  • 3
  • 27
  • 34
  • I am still not sure. How you tried doing this before? For Example: How would Hawtio plugins or jar files work with Mule and gets deployed a Hawtio browser on port 8080 alongside with mule deployments(both in the same run). But still Hawtio and Active MQ are known to get deployed within a single mule project. Take Java for example. If you have a java code, you can always add it to either a pom or a build path to work along with mule (using jars). No need of a separate java project for running java code right. Cant we do the same for pyDev project too ? – Thinker-101 Jan 12 '21 at 13:24
  • What about a Java project and pyDev project ? – Thinker-101 Jan 12 '21 at 13:25
  • That's a different question. I suggest to search previous questions on that topic: https://stackoverflow.com/questions/3596098/pydev-jython-modules-java-classes-in-the-same-project – aled Jan 12 '21 at 14:29
  • 2
    About your first question, both Mule Runtime and ActiveMQ are developed in Java. It is relatively easy to add Java code and jars to Mule application project. Support is built in. I'm not sure how Hawtio works but I guess it is activated by ActiveMQ libraries, but I'm pretty sure Mule doesn't know about it directly. Python is a different language. You can use the Scripting Module to integrate Python scripts with your Mule application projects as you want to execute the scripts. You probably want the developer experience in the IDE. I don't believe it is possible to integrate with Mule projects. – aled Jan 12 '21 at 20:58
1

For the PyDev side, you can mark any project as a PyDev project by right-clicking it and selecting PyDev > Set as PyDev Project (then you can go to the project properties: Alt+Enter with the project selected, select PyDev - PYTHONPATH and configure the PYTHONPATH to be used so that your own files are in source folders to be analyzed... see: https://www.pydev.org/manual_101_project_conf2.html for details).

So, what this would do is enable the PyDev developing experience (code completion, code analysis, etc) for Python files in this project.

Now, how to go on and integrate with Mule the actual Python code is up to you... (i.e.: maybe spawning a Python executable and using shared memory to share the data, using protobuf messages or just using the internal Jython integration -- I never did any of that, just sharing what could be a possibility).

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • "Spawning a python executable and shared memory"- That last bit excites me. I also must start looking at Jython integration as well once. Never tried it. Thanks! – Thinker-101 Jan 15 '21 at 04:05