`PythonSdkFlavor` detects pythons. It uses `VirtualEnvReader` under the hood (see virtual env flavor) and system pythons (see other flavors). We use it in `PythonLocalAddInterpreterModel` and cover it with tests PY-74425 WIP, PY-74236: `VirtualEnvReader` shouldn't return `null` nor should it check for dir existence, use `getVEnvRootDir` as a default dir for venv. The whole logic behind `VirtualEnvReader` is the following: we check for some env variable, and if it points to the correct path -- we use it. We fall back to the home directory otherwise. Directory doesn't need to exist (hence, no need to check `isDirectory`) because a client might always create it. Even worse: directory would probably not exist on a fresh OS, but a user still wants to create virtual envs there. PY-74425 WIP: Encapsulate python names and patterns inside `VirtualEnvReader`. `VirtualEnvReader` seems to be the main entry point to look for virtual envs on the local file system. Historically, flavors did that, so they had a set of names and patterns to filter python by name, however: 1. `UnixPythonSdkFlavor` had named for **nix only, and `VirtualEnvSdkFlavor` had names both for Windows and **nix. It is unlikely to see a `.exe ` file on **nix or file, without an extension on Windows, so this check is useless and broken (`VirtualEnvSdkFlavor` checks for both names on both OSes) 2. `UnixPythonSdkFlavor` had regex to filter Python2, but this python was removed 4 years ago and could hardly be met on any new OS; hence this check is useless. 3. New Project Wizard needs to find pythons, but knows nothing about names and patterns. Merge-request: IJ-MR-142040 Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com> GitOrigin-RevId: ce649b4f12f7c7b60a25d8e1fb1222e075337844
PyCharm Community Edition
The "python" directory in the source repository contains the source code of PyCharm Community Edition and the Python plugin for IntelliJ IDEA Community Edition.
Building and Running
The code is part of the main IntelliJ IDEA Community Edition project and is compiled together with the rest of the codebase. To run PyCharm Community Edition, please use the provided run configuration "PyCharm Community Edition". To run IntelliJ IDEA with the Python plugin, please use the "IDEA with Python plugin" run configuration.
To run the test suite, use the built-in JUnit test runner and run all tests in the "python-community-tests" module.
Building from the Command Line
To build the distribution archive of PyCharm Community Edition, execute build.xml Ant build script in this directory. The results of the build execution can be found at out/artifacts.
Building the Python Plugin
To build the Python plugin for IntelliJ IDEA Community Edition:
-
Download the .tar.gz distribution of the most recent EAP or release build of IntelliJ IDEA Community Edition;
-
Run the following command:
ant -Didea.path= -Didea.build.number=<build number of the build you're using> plugin
The .zip file of the built plugin will be placed at distCE/python-community-.SNAPSHOT.zip