Skip to content

Commit

Permalink
Delete the sample file that gets created on uv init
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Sep 27, 2024
1 parent 2c1176c commit e424d9d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/backends/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package python
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -776,13 +777,23 @@ func makePythonUvBackend() api.LanguageBackend {
defer span.Finish()
// Initalize the specfile if it doesnt exist
if !util.Exists("pyproject.toml") {
// uv (currently?) creates a "hello.py" on uv init. Ensure it gets deleted before control returns to the user.
sampleFileName := "hello.py"
if !util.Exists(sampleFileName) {
// Turns out it didn't exist after all!
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

0 comments on commit e424d9d

Please sign in to comment.