From 2c1176c158386312c41bde89bda8f57ce340cecb Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 27 Sep 2024 10:28:15 -0700 Subject: [PATCH 1/5] Disable uv README and .python-version --- internal/backends/python/python.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/backends/python/python.go b/internal/backends/python/python.go index b58343af..a3222680 100644 --- a/internal/backends/python/python.go +++ b/internal/backends/python/python.go @@ -776,7 +776,7 @@ 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"} + cmd := []string{"uv", "init", "--no-progress", "--no-readme", "--no-pin-python"} if projectName != "" { cmd = append(cmd, "--name", projectName) From 3add5467c95f2b52c702539b51a73f92165ee867 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 27 Sep 2024 10:33:55 -0700 Subject: [PATCH 2/5] Delete the sample file that gets created on uv init --- internal/backends/python/python.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/backends/python/python.go b/internal/backends/python/python.go index a3222680..c9ec2c01 100644 --- a/internal/backends/python/python.go +++ b/internal/backends/python/python.go @@ -4,6 +4,7 @@ package python import ( "context" "encoding/json" + "errors" "fmt" "io" "os" @@ -776,6 +777,13 @@ 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 != "" { @@ -783,6 +791,9 @@ func makePythonUvBackend() api.LanguageBackend { } util.RunCmd(cmd) + if sampleFileName != "" && util.Exists(sampleFileName) { + os.Remove(sampleFileName) + } } cmd := []string{"uv", "add"} From 95cc418069d34715a0604efee18b0d1f6f8446fa Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 27 Sep 2024 10:51:00 -0700 Subject: [PATCH 3/5] Comment --- internal/backends/python/python.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/backends/python/python.go b/internal/backends/python/python.go index c9ec2c01..de5c70f3 100644 --- a/internal/backends/python/python.go +++ b/internal/backends/python/python.go @@ -779,6 +779,7 @@ func makePythonUvBackend() api.LanguageBackend { 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 the user already _has_ a file called hello.py, do not delete it for them. if util.Exists(sampleFileName) { // Turns out it didn't exist after all! sampleFileName = "" From 5dcc863f2e4f88fd3385c89d49e90c33085da55e Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 27 Sep 2024 10:51:30 -0700 Subject: [PATCH 4/5] Remove comment --- internal/backends/python/python.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/backends/python/python.go b/internal/backends/python/python.go index de5c70f3..bda0549d 100644 --- a/internal/backends/python/python.go +++ b/internal/backends/python/python.go @@ -781,7 +781,6 @@ func makePythonUvBackend() api.LanguageBackend { sampleFileName := "hello.py" // If the user already _has_ a file called hello.py, do not delete it for them. if util.Exists(sampleFileName) { - // Turns out it didn't exist after all! sampleFileName = "" } From 35f1868e72f653b2a5901dde5c24dc14a2aca0c9 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 27 Sep 2024 11:00:40 -0700 Subject: [PATCH 5/5] Unused import --- internal/backends/python/python.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/backends/python/python.go b/internal/backends/python/python.go index bda0549d..596dc0d5 100644 --- a/internal/backends/python/python.go +++ b/internal/backends/python/python.go @@ -4,7 +4,6 @@ package python import ( "context" "encoding/json" - "errors" "fmt" "io" "os"