Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Release with new features and bugfixes:
* https://github.com/devonfw/IDEasy/issues/1853[#1853]: Add ARM releases for VSCode on Mac
* https://github.com/devonfw/IDEasy/issues/797[#797]: Use system unzip on macOS to preserve symlinks in ZIP extraction
* https://github.com/devonfw/IDEasy/issues/1723[#1723]: Add commandlet for GitHub Copilot CLI
* https://github.com/devonfw/IDEasy/pull/1885[#1885]: Add per-project uv tool isolation using UV_TOOL_DIR and UV_TOOL_BIN_DIR
* https://github.com/devonfw/IDEasy/issues/861[#861]: Fix install of pgadmin throws IllegalStateException when the install wizard starts
* https://github.com/devonfw/IDEasy/issues/1844[#1844]: VSCode plugin installation progress freezing
* https://github.com/devonfw/IDEasy/issues/1456[#1456]: Uninstall via Windows settings not working
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public void setEnvironment(EnvironmentContext environmentContext, ToolInstallati

super.setEnvironment(environmentContext, toolInstallation, additionalInstallation);
environmentContext.withEnvVar("VIRTUAL_ENV", toolInstallation.rootDir().toString());
environmentContext.withEnvVar("UV_TOOL_DIR", toolInstallation.rootDir().resolve("tools").toString());
environmentContext.withEnvVar("UV_TOOL_BIN_DIR", toolInstallation.binDir().toString());
Comment on lines +69 to +70
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need that also in Python commandlet?
Python has a dependency to uv and that causes the environment variables to be set already via Uv commandlet.
If we really need this it would be great to follow SoC and somehow extract a static method in Uv to be reused and called from here instead of duplicating it.
However, if possible my best suggestion would be to remove it here:

Suggested change
environmentContext.withEnvVar("UV_TOOL_DIR", toolInstallation.rootDir().resolve("tools").toString());
environmentContext.withEnvVar("UV_TOOL_BIN_DIR", toolInstallation.binDir().toString());

}

@Override
Expand Down
10 changes: 10 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/tool/uv/Uv.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.process.EnvironmentContext;
import com.devonfw.tools.ide.process.ProcessContext;
import com.devonfw.tools.ide.process.ProcessMode;
import com.devonfw.tools.ide.process.ProcessResult;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
import com.devonfw.tools.ide.tool.ToolInstallation;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
Expand Down Expand Up @@ -42,4 +44,12 @@ public void installPython(Path installationPath, VersionIdentifier resolvedVersi
ProcessResult result = runTool(processContext, ProcessMode.DEFAULT_CAPTURE, List.of("venv", "--python", resolvedVersion.toString()));
assert result.isSuccessful();
}
@Override
public void setEnvironment(EnvironmentContext environmentContext, ToolInstallation toolInstallation, boolean additionalInstallation) {

super.setEnvironment(environmentContext, toolInstallation, additionalInstallation);
Path pythonPath = this.context.getSoftwarePath().resolve("python");
environmentContext.withEnvVar("UV_TOOL_DIR", pythonPath.resolve("tools").toString());
environmentContext.withEnvVar("UV_TOOL_BIN_DIR", pythonPath.resolve("bin").toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.devonfw.tools.ide.tool.python;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
import com.devonfw.tools.ide.environment.VariableLine;
import com.devonfw.tools.ide.environment.VariableSource;
import com.devonfw.tools.ide.os.WindowsPathSyntax;
import com.devonfw.tools.ide.process.EnvironmentVariableCollectorContext;
import com.devonfw.tools.ide.tool.ToolInstallation;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
* Test of {@link Python}.
*/
public class PythonTest extends AbstractIdeContextTest {

@Test
public void testSetEnvironment() {

// arrange
IdeTestContext context = newContext(PROJECT_BASIC);
Python python = new Python(context);
Path rootDir = context.getSoftwarePath().resolve("python");
ToolInstallation toolInstallation = new ToolInstallation(rootDir, rootDir, rootDir.resolve("bin"), VersionIdentifier.of("3.12.0"), true);
Map<String, VariableLine> variables = new HashMap<>();
EnvironmentVariableCollectorContext environmentContext = new EnvironmentVariableCollectorContext(variables, new VariableSource(EnvironmentVariablesType.WORKSPACE, null), WindowsPathSyntax.MSYS);

// act
python.setEnvironment(environmentContext, toolInstallation, false);

// assert
assertThat(Path.of(variables.get("UV_TOOL_DIR").getValue())).isEqualTo(toolInstallation.rootDir().resolve("tools"));
assertThat(Path.of(variables.get("UV_TOOL_BIN_DIR").getValue())).isEqualTo(toolInstallation.binDir());
}
}
43 changes: 43 additions & 0 deletions cli/src/test/java/com/devonfw/tools/ide/tool/uv/UvTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.devonfw.tools.ide.tool.uv;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
import com.devonfw.tools.ide.environment.VariableLine;
import com.devonfw.tools.ide.environment.VariableSource;
import com.devonfw.tools.ide.os.WindowsPathSyntax;
import com.devonfw.tools.ide.process.EnvironmentVariableCollectorContext;
import com.devonfw.tools.ide.tool.ToolInstallation;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
* Test of {@link Uv}.
*/
public class UvTest extends AbstractIdeContextTest {

@Test
public void testSetEnvironment() {

// arrange
IdeTestContext context = newContext(PROJECT_BASIC);
Uv uv = new Uv(context);
Path rootDir = context.getSoftwarePath().resolve("uv");
ToolInstallation toolInstallation = new ToolInstallation(rootDir, rootDir, rootDir, VersionIdentifier.of("0.1.0"), true);
Map<String, VariableLine> variables = new HashMap<>();
EnvironmentVariableCollectorContext environmentContext = new EnvironmentVariableCollectorContext(variables, new VariableSource(EnvironmentVariablesType.WORKSPACE, null), WindowsPathSyntax.MSYS);

// act
uv.setEnvironment(environmentContext, toolInstallation, false);

// assert
Path expectedPythonPath = context.getSoftwarePath().resolve("python");
assertThat(Path.of(variables.get("UV_TOOL_DIR").getValue())).isEqualTo(expectedPythonPath.resolve("tools"));
assertThat(Path.of(variables.get("UV_TOOL_BIN_DIR").getValue())).isEqualTo(expectedPythonPath.resolve("bin"));
}
}
Loading