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

devonfw / IDEasy / 25315702124

04 May 2026 11:10AM UTC coverage: 70.653% (+0.006%) from 70.647%
25315702124

Pull #1885

github

web-flow
Merge 98ec42762 into 5b8af56a7
Pull Request #1885: 1518 uv tools are installed globally

4378 of 6848 branches covered (63.93%)

Branch coverage included in aggregate %.

11307 of 15352 relevant lines covered (73.65%)

3.12 hits per line

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

76.32
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.uv.Uv;
21
import com.devonfw.tools.ide.version.VersionIdentifier;
22

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

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

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

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

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

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

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

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

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

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

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

72
  @Override
73
  protected boolean isIgnoreSoftwareRepo() {
74

75
    return true;
2✔
76
  }
77

78
  /**
79
   * 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"
80
   * directory.
81
   *
82
   * @param fileAccess the {@link FileAccess} utility for file operations.
83
   * @param installationPath the path where Python is installed.
84
   */
85
  private void createWindowsSymlinkBinFolder(FileAccess fileAccess, Path installationPath) {
86

87
    if (!this.context.getSystemInfo().isWindows()) {
5!
88
      return;
1✔
89
    }
90
    Path scriptsPath = installationPath.resolve("Scripts");
×
91
    Path binPath = installationPath.resolve("bin");
×
92
    fileAccess.symlink(scriptsPath, binPath);
×
93
  }
×
94

95
  /**
96
   * Renames the ".venv" folder into the installation path (Python).
97
   *
98
   * @param fileAccess the {@link FileAccess} utility for file operations.
99
   * @param softwarePath the path where the software is installed.
100
   * @param installationPath the target path where the ".venv" folder should be moved.
101
   */
102
  private void renameVenvFolderToPython(FileAccess fileAccess, Path softwarePath, Path installationPath) {
103

104
    Path venvPath = softwarePath.resolve(".venv");
4✔
105
    fileAccess.move(venvPath, installationPath, StandardCopyOption.REPLACE_EXISTING);
10✔
106
  }
1✔
107

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