Skip to content

Commit

Permalink
bug/Proactively remove uv detritus (#294)
Browse files Browse the repository at this point in the history
* Disable uv README and .python-version

* Delete the sample file that gets created on uv init

* Comment

* Remove comment
  • Loading branch information
blast-hardcheese authored Sep 27, 2024
1 parent b04673f commit dd4c4b9
Showing 1 changed file with 11 additions and 1 deletion.
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) {
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 dd4c4b9

Please sign in to comment.