-
Notifications
You must be signed in to change notification settings - Fork 68
1518 uv tools are now installed locally #1885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ducminh02
wants to merge
7
commits into
devonfw:main
Choose a base branch
from
ducminh02:1518-uv-tools-are-installed-globally
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a95cb84
feat: configure XDG_BIN_HOME environment variable for Python and Uv w…
ducminh02 d3d978e
test: update XDG_BIN_HOME assertions to use Path objects instead of s…
ducminh02 98ec427
Merge branch 'main' into 1518-uv-tools-are-installed-globally
ducminh02 1a28337
refactor: replace XDG_BIN_HOME with UV_TOOL_DIR and UV_TOOL_BIN_DIR e…
ducminh02 1528813
Merge branch 'main' into 1518-uv-tools-are-installed-globally
ducminh02 267dc54
feat: add per-project uv tool isolation via environment variables in …
ducminh02 420e452
Merge branch 'main' into 1518-uv-tools-are-installed-globally
hohwille File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
cli/src/test/java/com/devonfw/tools/ide/tool/python/PythonTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
43
cli/src/test/java/com/devonfw/tools/ide/tool/uv/UvTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
Pythoncommandlet?Python has a dependency to
uvand that causes the environment variables to be set already viaUvcommandlet.If we really need this it would be great to follow SoC and somehow extract a static method in
Uvto be reused and called from here instead of duplicating it.However, if possible my best suggestion would be to remove it here: