Provide a public API to configure Python Console environment variables

My plugin integrates with the Python Console and needs to inject environment variables before the console starts.

Until recently, I was using PyConsoleOptions:

PyConsoleOptions.getInstance(project)
    .pythonConsoleSettings
    .envs = envs

However, PyConsoleOptions and its getInstance(Project) method are now marked as @ApiStatus.Internal:

@ApiStatus.Internal
companion object {
    @JvmStatic
    fun getInstance(project: Project): PyConsoleOptions =
        project.getService(PyConsoleOptions::class.java)
}

This leaves plugins without a supported way to configure environment variables for the Python Console.

Use Case

My plugin loads environment variables from external sources and injects them into the Python Console so that users can work interactively with the same environment as their application.

Example:

val envs = mapOf(
    "API_KEY" to "...",
    "DATABASE_URL" to "..."
)

PyConsoleOptions.getInstance(project)
    .pythonConsoleSettings
    .envs = envs

Request

Would it be possible to expose a stable public API to configure Python Console settings, or at least environment variables?

For example:

PythonConsoleManager.getInstance(project)
    .setEnvironmentVariables(envs)

or

PythonConsoleSettings.getInstance(project)
    .setEnvironmentVariables(envs)

Having a supported API would allow third-party plugins to integrate with the Python Console without relying on internal implementation details.

Additional Context

My plugin only needs to provide environment variables before the console is started. Access to the entire PyConsoleOptions implementation is not required; a minimal public API for reading/updating console environment variables would be sufficient.

If there is already another supported extension point or API intended for this use case, guidance would be greatly appreciated.

Could you please create an issue directly to the team?

To https://youtrack.jetbrains.com/issues/PY

this is the ticket: https://youtrack.jetbrains.com/issue/PY-90409/Provide-a-public-API-to-configure-Python-Console-environment-variables

@yuriy.artamonov this doesn’t make sense there is a class without internal annotation and jetbrains team mark the class and the only way to set environment variables as internal and don’t publish a way to do the same behavior. why don’t remove the annotation and the problem is fixed?

Sorry, I cannot comment anything new, you basically need response from the PyCharm team in the issue

@dalgarins hello! Yes, you’re right. While rewriting PyConsoleOptions in Kotlin, I marked it as @Internal. I’ll fix this shortly. You can track the progress here.