From 9f683ea190a4a1ff12fe11e718f3f5ea30863b5c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 28 Jul 2023 10:37:33 +0530 Subject: [PATCH] Store deps in per-platform dirs --- bypy/devenv.go | 20 +++++++++++++++++--- bypy/rsync.conf | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bypy/devenv.go b/bypy/devenv.go index a5fea2272..02452b834 100755 --- a/bypy/devenv.go +++ b/bypy/devenv.go @@ -19,6 +19,14 @@ import ( const folder = "dependencies" +func root_dir() string { + f, e := filepath.Abs(filepath.Join(folder, runtime.GOOS+"-"+runtime.GOARCH)) + if e != nil { + panic(e) + } + return f +} + var _ = fmt.Print func exit(x any) { @@ -129,14 +137,14 @@ func dependencies(args []string) { exit("Prebuilt dependencies are only available for Linux and macOS") } url = strings.Replace(url, "{}", which, 1) - if err := os.RemoveAll(filepath.Join(folder, "root")); err != nil { + if err := os.RemoveAll(root_dir()); err != nil { exit(err) } if err := os.MkdirAll(folder, 0o755); err != nil { exit(err) } tarfile, _ := filepath.Abs(cached_download(url)) - root, _ := filepath.Abs(filepath.Join(folder, "root")) + root := root_dir() if err := os.MkdirAll(root, 0o755); err != nil { exit(err) } @@ -186,9 +194,15 @@ func build(args []string) { dependencies(nil) } python := "" - root, _ := filepath.Abs(filepath.Join(folder, "root")) + root := root_dir() os.Setenv("DEVELOP_ROOT", root) prepend("PKG_CONFIG_PATH", filepath.Join(root, "lib", "pkgconfig")) + for _, x := range os.Environ() { + if strings.HasPrefix(x, "PYTHON") { + a, _, _ := strings.Cut(x, "=") + os.Unsetenv(a) + } + } switch runtime.GOOS { case "linux": prepend("LD_LIBRARY_PATH", filepath.Join(root, "lib")) diff --git a/bypy/rsync.conf b/bypy/rsync.conf index 5fd61f610..c016f98eb 100644 --- a/bypy/rsync.conf +++ b/bypy/rsync.conf @@ -1 +1 @@ -to_vm_excludes '/build /dist /kitty/launcher/kitty* /.build-cache /tags __pycache__ /*_commands.json *.so *.pyd *.pyc *_generated.go' +to_vm_excludes '/dependencies /build /dist /kitty/launcher/kitty* /.build-cache /tags __pycache__ /*_commands.json *.so *.pyd *.pyc *_generated.go'