Skip to content
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

bug/Proactively remove uv detritus #294

Merged
merged 5 commits into from
Sep 27, 2024
Merged
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
12 changes: 11 additions & 1 deletion internal/backends/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,23 @@ func makePythonUvBackend() api.LanguageBackend {
defer span.Finish()
// Initalize the specfile if it doesnt exist
if !util.Exists("pyproject.toml") {
cmd := []string{"uv", "init", "--no-progress"}
// uv (currently?) creates a "hello.py" on uv init. Ensure it gets deleted before control returns to the user.
sampleFileName := "hello.py"
// If the user already _has_ a file called hello.py, do not delete it for them.
if util.Exists(sampleFileName) {
blast-hardcheese marked this conversation as resolved.
Show resolved Hide resolved
sampleFileName = ""
}

cmd := []string{"uv", "init", "--no-progress", "--no-readme", "--no-pin-python"}

if projectName != "" {
cmd = append(cmd, "--name", projectName)
}

util.RunCmd(cmd)
if sampleFileName != "" && util.Exists(sampleFileName) {
os.Remove(sampleFileName)
}
}

cmd := []string{"uv", "add"}
Expand Down
Loading