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

devonfw / IDEasy / 16903311797

12 Aug 2025 08:25AM UTC coverage: 69.308% (-0.2%) from 69.463%
16903311797

Pull #1442

github

web-flow
Merge 825387149 into 8e46cb00a
Pull Request #1442: #1384: Add python support via uv

3356 of 5278 branches covered (63.58%)

Branch coverage included in aggregate %.

8671 of 12075 relevant lines covered (71.81%)

3.16 hits per line

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

6.9
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 com.devonfw.tools.ide.common.Tag;
9
import com.devonfw.tools.ide.context.IdeContext;
10
import com.devonfw.tools.ide.io.FileAccess;
11
import com.devonfw.tools.ide.process.EnvironmentContext;
12
import com.devonfw.tools.ide.process.ProcessContext;
13
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
14
import com.devonfw.tools.ide.tool.ToolCommandlet;
15
import com.devonfw.tools.ide.tool.ToolInstallation;
16
import com.devonfw.tools.ide.tool.repository.ToolRepository;
17
import com.devonfw.tools.ide.tool.uv.Uv;
18
import com.devonfw.tools.ide.version.VersionIdentifier;
19

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

25
  /**
26
   * The constructor.
27
   *
28
   * @param context the {@link IdeContext}.
29
   */
30
  public Python(IdeContext context) {
31

32
    super(context, "python", Set.of(Tag.PYTHON));
6✔
33
  }
1✔
34

35
  /**
36
   * Installs {@code python} using the {@link Uv#installPython(Path, VersionIdentifier, ProcessContext)} method.
37
   * <p>
38
   * Unlike the base implementation, this method requires the {@link ProcessContext} to perform the installation logic specific to {@code python}.
39
   *
40
   * @param toolRepository the {@link ToolRepository}, unused in this implementation.
41
   * @param resolvedVersion the {@link VersionIdentifier} of the {@code python} tool to install.
42
   * @param installationPath the target {@link Path} where the tool should be installed.
43
   * @param fileAccess the {@link FileAccess} utility for file operations.
44
   * @param edition the edition of the tool to install, unused in this implementation.
45
   * @param processContext the {@link ProcessContext} required to install the Python environment.
46
   */
47
  @Override
48
  protected void performToolInstallation(ToolRepository toolRepository, VersionIdentifier resolvedVersion, Path installationPath, FileAccess fileAccess,
49
      String edition, ProcessContext processContext) {
50

51
    if (Files.exists(installationPath)) {
×
52
      fileAccess.backup(installationPath);
×
53
    }
54
    Path softwarePath = installationPath.getParent();
×
55
    Uv uv = this.context.getCommandletManager().getCommandlet(Uv.class);
×
56

57
    uv.installPython(softwarePath, resolvedVersion, processContext);
×
58
    renameVenvFolderToPython(fileAccess, softwarePath, installationPath);
×
59
    this.context.writeVersionFile(resolvedVersion, installationPath);
×
60
    createWindowsSymlinkBinFolder(fileAccess, installationPath);
×
61
    this.context.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath);
×
62
  }
×
63

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

67
    super.setEnvironment(environmentContext, toolInstallation, extraInstallation);
×
68
    environmentContext.withEnvVar("VIRTUAL_ENV", toolInstallation.rootDir().toString());
×
69
  }
×
70

71
  @Override
72
  protected boolean isIgnoreSoftwareRepo() {
73

74
    return true;
×
75
  }
76

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

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

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

103
    Path venvPath = softwarePath.resolve(".venv");
×
104
    fileAccess.move(venvPath, installationPath, StandardCopyOption.REPLACE_EXISTING);
×
105
  }
×
106

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