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

devonfw / IDEasy / 32126869284

18 Aug 2026 10:27AM UTC coverage: 72.901% (-0.007%) from 72.908%
32126869284

Pull #2330

github

web-flow
Merge b39298009 into 5cc347744
Pull Request #2330: #2313: Fixed python installation failing

5109 of 7763 branches covered (65.81%)

Branch coverage included in aggregate %.

13351 of 17559 relevant lines covered (76.04%)

3.23 hits per line

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

76.19
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 pythonMinVersion = VersionIdentifier.of("3.8.2");
4✔
32

33
  /** The folder created by {@code uv venv} inside the software folder before it is renamed to the python installation. */
34
  protected static final String VENV_FOLDER = ".venv";
35

36
  /**
37
   * The constructor.
38
   *
39
   * @param context the {@link IdeContext}.
40
   */
41
  public Python(IdeContext context) {
42

43
    super(context, "python", Set.of(Tag.PYTHON));
6✔
44
  }
1✔
45

46
  @Override
47
  protected void performToolInstallation(ToolInstallRequest request, Path installationPath) {
48

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

54
    FileAccess fileAccess = this.context.getFileAccess();
4✔
55
    if (Files.exists(installationPath)) {
5!
56
      fileAccess.backup(installationPath);
×
57
    }
58
    Path softwarePath = installationPath.getParent();
3✔
59
    Path venvPath = softwarePath.resolve(VENV_FOLDER);
4✔
60

61
    fileAccess.delete(venvPath);
3✔
62

63
    Uv uv = this.context.getCommandletManager().getCommandlet(Uv.class);
7✔
64

65
    uv.installPython(softwarePath, resolvedVersion, request.getProcessContext());
6✔
66
    renameVenvFolderToPython(fileAccess, softwarePath, installationPath);
5✔
67
    this.context.writeVersionFile(resolvedVersion, installationPath);
5✔
68
    createWindowsSymlinkBinFolder(fileAccess, installationPath);
4✔
69
    LOG.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath);
18✔
70
  }
1✔
71

72
  @Override
73
  public void setEnvironment(EnvironmentContext environmentContext, ToolInstallation toolInstallation, boolean additionalInstallation) {
74

75
    super.setEnvironment(environmentContext, toolInstallation, additionalInstallation);
5✔
76
    environmentContext.withEnvVar("VIRTUAL_ENV", toolInstallation.rootDir().toString());
7✔
77
    environmentContext.withEnvVar("UV_PROJECT_ENVIRONMENT", toolInstallation.rootDir().toString());
7✔
78
  }
1✔
79

80
  @Override
81
  protected boolean isIgnoreSoftwareRepo() {
82

83
    return true;
2✔
84
  }
85

86
  @Override
87
  protected boolean isIgnoreMissingSoftwareVersionFile() {
88

89
    // https://github.com/devonfw/IDEasy/issues/2190
90
    return true;
×
91
  }
92

93
  @Override
94
  public ToolRepository getToolRepository() {
95

96
    return this.context.getPythonRepository();
4✔
97
  }
98

99
  /**
100
   * 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"
101
   * directory.
102
   *
103
   * @param fileAccess the {@link FileAccess} utility for file operations.
104
   * @param installationPath the path where Python is installed.
105
   */
106
  private void createWindowsSymlinkBinFolder(FileAccess fileAccess, Path installationPath) {
107

108
    if (!this.context.getSystemInfo().isWindows()) {
5!
109
      return;
1✔
110
    }
111
    Path scriptsPath = installationPath.resolve("Scripts");
×
112
    Path binPath = installationPath.resolve("bin");
×
113
    fileAccess.symlink(scriptsPath, binPath);
×
114
  }
×
115

116
  /**
117
   * Renames the ".venv" folder into the installation path (Python).
118
   *
119
   * @param fileAccess the {@link FileAccess} utility for file operations.
120
   * @param softwarePath the path where the software is installed.
121
   * @param installationPath the target path where the ".venv" folder should be moved.
122
   */
123
  private void renameVenvFolderToPython(FileAccess fileAccess, Path softwarePath, Path installationPath) {
124

125
    Path venvPath = softwarePath.resolve(VENV_FOLDER);
4✔
126
    fileAccess.move(venvPath, installationPath, StandardCopyOption.REPLACE_EXISTING);
10✔
127
  }
1✔
128

129
}
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