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

devonfw / IDEasy / 29848115811

21 Jul 2026 04:20PM UTC coverage: 72.514% (+0.03%) from 72.484%
29848115811

push

github

web-flow
#2100: Resolve python versions via uv instead of ide-urls (#2152)

Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>
Co-authored-by: Philipp Hoang <115173117+Caylipp@users.noreply.github.com>

4973 of 7584 branches covered (65.57%)

Branch coverage included in aggregate %.

12824 of 16959 relevant lines covered (75.62%)

3.2 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.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
  public ToolRepository getToolRepository() {
80

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

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

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

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

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

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