Running python scripts inside a ItelliJ IDEA plugIn

已回答

Hi All,

I am currently integrating a python script into my plug-in project which is developed by Kotlin.

Just wonder if there are any suggestions on this?

Running a python script requires a python interpreter installed. Also, this python script also required to install some python libs ahead (e.g. lark, ninja)

The are two possible ways I can think of:

  1. Using pyinstaller to pack the script into executables, and run it as an executable file.
  2. Install all requirements (python interpreter, libs)  and run the script.

Not sure if there is any better way to do so.

Any help will be appreciated!

0

Hi Wwwpopop! You can add dependency on Python plugin and reuse all this functionality from it. In Python plugin you can configure Python SDK, specify it to a module and install needed packages through our packaging tool.
As an example you can look at a MicroPython plugin implementation https://github.com/JetBrains/intellij-micropython (which works both in PyCharm and Intellij Idea)

0

Hi Elizabeth,

Thank you! This is really helpful!

Btw, is the Python plugin supported in Android Studio too?

I meant, can I add a dependency on the Python plugin to my Android Studio plugin project?

 

 

0

Thanks Elizabeth!

I am wondering if this approach is suitable for my project, which is a plugin for Android app projects using Java or Kotlin.

After trying this solution, I have some questions.

  1. In order to use the functionality of the Python Community plugin, it appears that users have to manually set up the facet. Can I remove the Facet setting and use the functionality of PythonCore to install the interpreter and libraries directly?
  2. If the user does not use Python to code in the project, can my plugin install the Python interpreter? It seems like intellij-micropython is a plugin for python project. 
  3. Where can I find the document or example about using functionality of PythonCore plugin?

I am not sure if I should ask them in this thread. If I should have another post for it, let me know. Thanks again.

0

Hi! 
1. Yes, the facet isn't mandatory for interpreter configuration. You still can configure a "Python SDK" and install any necessary packages which are needed
2. Installing Python interpreter isn't supported, but you can request users to configure interpreter which is already installed on their machine. 
3. I'm afraid, there is no such document :( You can look into the intellij-community codebase or ask your questions here, in this thread.

0

请先登录再写评论。