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

devonfw / IDEasy / 30004650583

23 Jul 2026 11:50AM UTC coverage: 72.542% (+0.05%) from 72.496%
30004650583

Pull #2205

github

web-flow
Merge a17499a89 into 5b6cc3011
Pull Request #2205: #2197: fixed-python-integration

4978 of 7584 branches covered (65.64%)

Branch coverage included in aggregate %.

12826 of 16959 relevant lines covered (75.63%)

3.2 hits per line

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

76.92
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
    environmentContext.withEnvVar("UV_PROJECT_ENVIRONMENT", toolInstallation.rootDir().toString());
7✔
71
  }
1✔
72

73
  @Override
74
  protected boolean isIgnoreSoftwareRepo() {
75

76
    return true;
2✔
77
  }
78

79
  @Override
80
  public ToolRepository getToolRepository() {
81

82
    return this.context.getPythonRepository();
4✔
83
  }
84

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

94
    if (!this.context.getSystemInfo().isWindows()) {
5!
95
      return;
1✔
96
    }
97
    Path scriptsPath = installationPath.resolve("Scripts");
×
98
    Path binPath = installationPath.resolve("bin");
×
99
    fileAccess.symlink(scriptsPath, binPath);
×
100
  }
×
101

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

111
    Path venvPath = softwarePath.resolve(".venv");
4✔
112
    fileAccess.move(venvPath, installationPath, StandardCopyOption.REPLACE_EXISTING);
10✔
113
  }
1✔
114

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