Intellij Pycharm Plugin using python-ce.zip

已回答

Hi, I'm writing a Pycharm plugin where I wanted to use the Python Package Manager class:

var pck = PyPackageManager.getInstance(projectSdk).getPackages();

For that, I needed to add the python-ce.jar from IntelliJ plugins directory (extracted from python-ce.zip) into my libs folder, and add this to my gradle build script:

dependencies
{
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}

The project builds fine, but the when the Pycharm starts, I get an error notification and my plugin is not visible or accessible:

java.lang.Throwable: Assertion failed: Helpers root does not exist C:\Users\<user>\source\repos\RsIC\build\idea-sandbox\plugins\RsConnectivityPycharmPlugin\helpers

I tried to copy the helpers folder (extracted from python-ce.zip) to the desired path, but the Pycharm starts without the plugin being visible or accessible, and the IntelliJ reports Debug info:

WARN - #c.i.e.t.TargetBasedSdks - SDK target configuration data is absent
WARN - #c.j.p.c.u.PyUserSkeletonsUtil - python-skeletons directory not found in paths: [C:\Users\<user>\source\repos\RsIC\build\idea-sandbox\config\python-skeletons, C:\Users\<user>\source\repos\RsIC\build\idea-sandbox\plugins\RsConnectivityPycharmPlugin\helpers\python-skeletons]

 

My question is: How do I configure my project to be able to use the python-ce classes and run the Pycharm with my plugin?

I am using Win 10 with IntelliJ Build #IC-222.3345.118, built on July 26, 2022

 

gradle.build:

plugins
{
id 'java'
id 'org.jetbrains.intellij' version '1.8.0'
id 'maven-publish'
}

intellij
{
version = '2022.2'
type = 'PC'
}

buildSearchableOptions
{
enabled = false
}

dependencies
{
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

}

test {
useJUnitPlatform()
}

patchPluginXml
{
version = project.version
sinceBuild = '210.*'
untilBuild = '250.*'
}

Thanks,

Milo

评论操作 固定链接

Hi Miloslav,

You shouldn't copy any JAR from Python or other plugins/IDEs and handle them manually. The classes are present in the IDE if it supports it, and you should never make them part of your plugin distribution.

What you need to do is:

  1. In your Gradle build script, add:
    intellij {
       version = '2022.2'
    type = 'PC'
    plugins = ["PythonCore"]
    }
  2. In plugin.xml, add:
    <depends>com.intellij.modules.python</depends>

 This is all that is needed. The PyPackageManager will be available to use in your project.

This information can be found on: https://plugins.jetbrains.com/docs/intellij/pycharm.html

0
评论操作 固定链接

Hi Karol,

 

thx for the quick and perfect response, I saw many people struggling with this problem, but no discussion thread lead to a solution that worked for me. This one nailed it... Thanks again,

 

Milo

0

请先登录再写评论。