From dd4c4b9eae8c8db300f57c804aa72ebd163a8e4c Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 27 Sep 2024 18:16:56 +0000 Subject: [PATCH] bug/Proactively remove uv detritus (#294) * Disable uv README and .python-version * Delete the sample file that gets created on uv init * Comment * Remove comment --- internal/backends/python/python.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/backends/python/python.go b/internal/backends/python/python.go index b58343af..596dc0d5 100644 --- a/internal/backends/python/python.go +++ b/internal/backends/python/python.go @@ -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"}