From 011f905e837a8421c6b5b02a165765d6e1da9348 Mon Sep 17 00:00:00 2001 From: Korenevskiy Denis Date: Wed, 4 Sep 2024 16:07:46 +0300 Subject: [PATCH] correct way to detect current executable path --- package.json | 4 ++-- runenv-python-stub.go | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9dc1c5c..14be7d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@milaboratory/small-binaries", - "version": "1.10.0", + "version": "1.10.1", "description": "Small cross-platform binaries, like 'sleep' or 'hello-world', suitable for test needs", "scripts": { "cleanup": "rm -rf ./pkg-*.tgz && rm -rf ./build/ && rm -rf ./dist/", @@ -89,7 +89,7 @@ "runenv-python-stub": { "registry": "milaboratories" , - "version": "1.0.0", + "version": "1.0.1", "type": "environment", "runtime": "python", "roots": { diff --git a/runenv-python-stub.go b/runenv-python-stub.go index 0c2bb1b..454374c 100644 --- a/runenv-python-stub.go +++ b/runenv-python-stub.go @@ -30,7 +30,7 @@ func main() { if isVenvCreation(os.Args) { createFakeVenv(os.Args) - fmt.Fprintf(os.Stdout, "venv directory created") + fmt.Fprintf(os.Stdout, "venv directory created\n") return } } @@ -53,8 +53,11 @@ func createFakeVenv(args []string) { "python stub: failed to create %q dir", binDir, ) - must(copyFile(args[0], filepath.Join(binDir, "python")), "failed to put 'python' into %q", binDir) - must(copyFile(args[0], filepath.Join(binDir, "pip")), "failed to put 'pip' into %q", binDir) + exec, err := os.Executable() + must(err, "failed to get current executable path") + + must(copyFile(exec, filepath.Join(binDir, "python")), "failed to put 'python' into %q", binDir) + must(copyFile(exec, filepath.Join(binDir, "pip")), "failed to put 'pip' into %q", binDir) } func copyFile(src, dst string) error {