List<String> (@NotNull List<String> existingInterpreterParameters) { var sdk = myPyState.getSdk(); if (sdk == null) { return Collections.emptyList(); } var pythonVersion = sdk.getVersionString(); if (pythonVersion == null) { return Collections.emptyList(); } var pythonSdkFlavor = PySdkExtKt.getOrCreateAdditionalData(sdk).getFlavor(); if (!(pythonSdkFlavor instanceof CPythonSdkFlavor)) { return Collections.emptyList(); } // Note, that we don't modify the parameters if the options are already set by the user. if (pythonSdkFlavor.getLanguageLevel(sdk).isOlderThan(LanguageLevel.PYTHON38)) { // There is no option for defining a custom directory for .pyc files in Python 3.7 and older, thus disable cache generation entirely. if (!existingInterpreterParameters.contains(PYTHON_DONT_WRITE_PYC_FLAG)) { return List.of(PYTHON_DONT_WRITE_PYC_FLAG); } } else { for (int i = 0; i < existingInterpreterParameters.size(); i++) { if (existingInterpreterParameters.get(i).startsWith(PYTHON3_PYCACHE_PREFIX_OPTION) && i > 0 && existingInterpreterParameters.get(i - 1).equals("-X")) { return Collections.emptyList(); } } return List.of( "-X", PYTHON3_PYCACHE_PREFIX_OPTION + prepareAndGetPycacheDirectory()); } return Collections.emptyList(); }