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

devonfw / IDEasy / 30625562134

31 Jul 2026 11:01AM UTC coverage: 72.613% (-0.03%) from 72.641%
30625562134

Pull #2212

github

web-flow
Merge 36165b9ca into 468118d46
Pull Request #2212: #2190: IDEasy destroys python installation

5023 of 7653 branches covered (65.63%)

Branch coverage included in aggregate %.

13086 of 17286 relevant lines covered (75.7%)

3.21 hits per line

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

74.36
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 org.slf4j.Logger;
9
import org.slf4j.LoggerFactory;
10

11
import com.devonfw.tools.ide.cli.CliException;
12
import com.devonfw.tools.ide.common.Tag;
13
import com.devonfw.tools.ide.context.IdeContext;
14
import com.devonfw.tools.ide.io.FileAccess;
15
import com.devonfw.tools.ide.process.EnvironmentContext;
16
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
17
import com.devonfw.tools.ide.tool.ToolCommandlet;
18
import com.devonfw.tools.ide.tool.ToolInstallRequest;
19
import com.devonfw.tools.ide.tool.ToolInstallation;
20
import com.devonfw.tools.ide.tool.repository.ToolRepository;
21
import com.devonfw.tools.ide.tool.uv.Uv;
22
import com.devonfw.tools.ide.version.VersionIdentifier;
23

24
/**
25
 * {@link ToolCommandlet} for <a href="https://www.python.org/">python</a>.
26
 */
27
public class Python extends LocalToolCommandlet {
28

29
  private static final Logger LOG = LoggerFactory.getLogger(Python.class);
4✔
30

31
  private final VersionIdentifier PYTHON_MIN_VERSION = VersionIdentifier.of("3.8.2");
4✔
32

33
  /**
34
   * The constructor.
35
   *
36
   * @param context the {@link IdeContext}.
37
   */
38
  public Python(IdeContext context) {
39

40
    super(context, "python", Set.of(Tag.PYTHON));
6✔
41
  }
1✔
42

43
  @Override
44
  protected void performToolInstallation(ToolInstallRequest request, Path installationPath) {
45

46
    VersionIdentifier resolvedVersion = request.getRequested().getResolvedVersion();
4✔
47
    if (resolvedVersion.compareVersion(PYTHON_MIN_VERSION).isLess()) {
6!
48
      throw new CliException("Python version must be at least " + this.PYTHON_MIN_VERSION);
×
49
    }
50

51
    FileAccess fileAccess = this.context.getFileAccess();
4✔
52
    if (Files.exists(installationPath)) {
5!
53
      fileAccess.backup(installationPath);
×
54
    }
55
    Path softwarePath = installationPath.getParent();
3✔
56
    Uv uv = this.context.getCommandletManager().getCommandlet(Uv.class);
7✔
57

58
    uv.installPython(softwarePath, resolvedVersion, request.getProcessContext());
6✔
59
    renameVenvFolderToPython(fileAccess, softwarePath, installationPath);
5✔
60
    this.context.writeVersionFile(resolvedVersion, installationPath);
5✔
61
    createWindowsSymlinkBinFolder(fileAccess, installationPath);
4✔
62
    LOG.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath);
18✔
63
  }
1✔
64

65
  @Override
66
  public void setEnvironment(EnvironmentContext environmentContext, ToolInstallation toolInstallation, boolean additionalInstallation) {
67

68
    super.setEnvironment(environmentContext, toolInstallation, additionalInstallation);
5✔
69
    environmentContext.withEnvVar("VIRTUAL_ENV", toolInstallation.rootDir().toString());
7✔
70
  }
1✔
71

72
  @Override
73
  protected boolean isIgnoreSoftwareRepo() {
74

75
    return true;
2✔
76
  }
77

78
  @Override
79
  protected boolean isIgnoreMissingSoftwareVersionFile() {
80

81
    return true;
×
82
  }
83

84
  @Override
85
  public ToolRepository getToolRepository() {
86

87
    return this.context.getPythonRepository();
4✔
88
  }
89

90
  /**
91
   * 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"
92
   * directory.
93
   *
94
   * @param fileAccess the {@link FileAccess} utility for file operations.
95
   * @param installationPath the path where Python is installed.
96
   */
97
  private void createWindowsSymlinkBinFolder(FileAccess fileAccess, Path installationPath) {
98

99
    if (!this.context.getSystemInfo().isWindows()) {
5!
100
      return;
1✔
101
    }
102
    Path scriptsPath = installationPath.resolve("Scripts");
×
103
    Path binPath = installationPath.resolve("bin");
×
104
    fileAccess.symlink(scriptsPath, binPath);
×
105
  }
×
106

107
  /**
108
   * Renames the ".venv" folder into the installation path (Python).
109
   *
110
   * @param fileAccess the {@link FileAccess} utility for file operations.
111
   * @param softwarePath the path where the software is installed.
112
   * @param installationPath the target path where the ".venv" folder should be moved.
113
   */
114
  private void renameVenvFolderToPython(FileAccess fileAccess, Path softwarePath, Path installationPath) {
115

116
    Path venvPath = softwarePath.resolve(".venv");
4✔
117
    fileAccess.move(venvPath, installationPath, StandardCopyOption.REPLACE_EXISTING);
10✔
118
  }
1✔
119

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

© 2026 Coveralls, Inc