-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Close #9871: add uv self uninstall command #11613
Draft
loic-lescoat
wants to merge
9
commits into
astral-sh:main
Choose a base branch
from
loic-lescoat:uv-self-uninstall-v2
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.
+190
−2
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d6047f9
Close #9871: add uv self uninstall command
0462012
remove reference to non-existing file
a057630
bugfixes: executable suffix; and don_t use fs; and generate doc
4104fc8
rename command line option for data removal and use of std::env::consts
bfbe89f
fix compiler error in cache reference
e96b0f0
fix: don't hardcode path of executable
d354167
add smoke test
e9435b7
can self uninstall iff can self update
d4965af
escape braces
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 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 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 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 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,45 @@ | ||
use anyhow::Result; | ||
|
||
use crate::commands::cache_clean; | ||
use crate::commands::ExitStatus; | ||
use crate::printer::Printer; | ||
use std::env; | ||
use uv_cache::rm_rf; | ||
use uv_cache::Cache; | ||
use uv_python::managed::ManagedPythonInstallations; | ||
use uv_tool::InstalledTools; | ||
|
||
pub(crate) fn self_uninstall( | ||
cache: &Cache, | ||
printer: Printer, | ||
remove_data: bool, | ||
) -> Result<ExitStatus> { | ||
if remove_data { | ||
// uv cache clean | ||
cache_clean(&[], cache, printer)?; | ||
|
||
// rm -r "$(uv python dir)" | ||
let installed_toolchains = ManagedPythonInstallations::from_settings(None)?; | ||
let python_directory = installed_toolchains.root(); | ||
rm_rf(python_directory)?; | ||
|
||
// rm -r "$(uv tool dir)" | ||
let installed_tools = InstalledTools::from_settings()?; | ||
let tools_path = installed_tools.root(); | ||
rm_rf(tools_path)?; | ||
} | ||
|
||
// Remove uv and uvx binaries | ||
// rm ~/.local/bin/uv ~/.local/bin/uvx | ||
|
||
let uv_executable = env::current_exe().unwrap(); | ||
let uv_path = uv_executable.as_path(); | ||
// We assume uvx executable is in same directory as uv executable | ||
let uvx_executable = uv_path.with_file_name(format!("uvx{}", std::env::consts::EXE_SUFFIX)); | ||
let uvx_path = uvx_executable.as_path(); | ||
|
||
rm_rf(uv_path)?; | ||
rm_rf(uvx_path)?; | ||
|
||
Ok(ExitStatus::Success) | ||
} |
This file contains 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 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
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.
I wonder if we should require the uv installer to have been used to enable this? Like we do in
self_update
If so, that'd give us another way to determine the canonical install path.
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.
Good point. Is it fair to say that the uv installer was used iff
uv
was built with theself-update
feature? In other words, is it reasonable to enable theuv self uninstall
command iff theuv self update
command is enabled?Thanks.
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.
I think you can check for a receipt like the
update
command does.This also makes sense to me.