• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 19751480105

28 Nov 2025 01:26AM UTC coverage: 69.441% (+0.3%) from 69.136%
19751480105

push

github

web-flow
#1613: fixed duplicated CVE check and refactored installation routine (#1614)

3696 of 5851 branches covered (63.17%)

Branch coverage included in aggregate %.

9620 of 13325 relevant lines covered (72.2%)

3.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.33
cli/src/main/java/com/devonfw/tools/ide/tool/python/Python.java
1
package com.devonfw.tools.ide.tool.python;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.nio.file.StandardCopyOption;
6
import java.util.Set;
7

8
import com.devonfw.tools.ide.cli.CliException;
9
import com.devonfw.tools.ide.common.Tag;
10
import com.devonfw.tools.ide.context.IdeContext;
11
import com.devonfw.tools.ide.io.FileAccess;
12
import com.devonfw.tools.ide.process.EnvironmentContext;
13
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
14
import com.devonfw.tools.ide.tool.ToolCommandlet;
15
import com.devonfw.tools.ide.tool.ToolInstallRequest;
16
import com.devonfw.tools.ide.tool.ToolInstallation;
17
import com.devonfw.tools.ide.tool.uv.Uv;
18
import com.devonfw.tools.ide.version.VersionIdentifier;
19

20
/**
21
 * {@link ToolCommandlet} for <a href="https://www.python.org/">python</a>.
22
 */
23
public class Python extends LocalToolCommandlet {
24

25
  private final VersionIdentifier PYTHON_MIN_VERSION = VersionIdentifier.of("3.8.2");
4✔
26

27
  /**
28
   * The constructor.
29
   *
30
   * @param context the {@link IdeContext}.
31
   */
32
  public Python(IdeContext context) {
33

34
    super(context, "python", Set.of(Tag.PYTHON));
6✔
35
  }
1✔
36

37
  @Override
38
  protected void performToolInstallation(ToolInstallRequest request, Path installationPath) {
39

40
    VersionIdentifier resolvedVersion = request.getRequested().getResolvedVersion();
×
41
    if (resolvedVersion.compareVersion(PYTHON_MIN_VERSION).isLess()) {
×
42
      throw new CliException("Python version must be at least " + this.PYTHON_MIN_VERSION);
×
43
    }
44

45
    FileAccess fileAccess = this.context.getFileAccess();
×
46
    if (Files.exists(installationPath)) {
×
47
      fileAccess.backup(installationPath);
×
48
    }
49
    Path softwarePath = installationPath.getParent();
×
50
    Uv uv = this.context.getCommandletManager().getCommandlet(Uv.class);
×
51

52
    uv.installPython(softwarePath, resolvedVersion, request.getProcessContext());
×
53
    renameVenvFolderToPython(fileAccess, softwarePath, installationPath);
×
54
    this.context.writeVersionFile(resolvedVersion, installationPath);
×
55
    createWindowsSymlinkBinFolder(fileAccess, installationPath);
×
56
    this.context.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath);
×
57
  }
×
58

59
  @Override
60
  public void setEnvironment(EnvironmentContext environmentContext, ToolInstallation toolInstallation, boolean extraInstallation) {
61

62
    super.setEnvironment(environmentContext, toolInstallation, extraInstallation);
×
63
    environmentContext.withEnvVar("VIRTUAL_ENV", toolInstallation.rootDir().toString());
×
64
  }
×
65

66
  @Override
67
  protected boolean isIgnoreSoftwareRepo() {
68

69
    return true;
×
70
  }
71

72
  /**
73
   * Creates a symlink from the "Scripts" folder to the "bin" folder on Windows systems. This is necessary for compatibility with tools that expect a "bin"
74
   * directory.
75
   *
76
   * @param fileAccess the {@link FileAccess} utility for file operations.
77
   * @param installationPath the path where Python is installed.
78
   */
79
  private void createWindowsSymlinkBinFolder(FileAccess fileAccess, Path installationPath) {
80

81
    if (!this.context.getSystemInfo().isWindows()) {
×
82
      return;
×
83
    }
84
    Path scriptsPath = installationPath.resolve("Scripts");
×
85
    Path binPath = installationPath.resolve("bin");
×
86
    fileAccess.symlink(scriptsPath, binPath);
×
87
  }
×
88

89
  /**
90
   * Renames the ".venv" folder into the installation path (Python).
91
   *
92
   * @param fileAccess the {@link FileAccess} utility for file operations.
93
   * @param softwarePath the path where the software is installed.
94
   * @param installationPath the target path where the ".venv" folder should be moved.
95
   */
96
  private void renameVenvFolderToPython(FileAccess fileAccess, Path softwarePath, Path installationPath) {
97

98
    Path venvPath = softwarePath.resolve(".venv");
×
99
    fileAccess.move(venvPath, installationPath, StandardCopyOption.REPLACE_EXISTING);
×
100
  }
×
101

102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc