diff --git a/internal/env/env.go b/internal/env/env.go index a0665b2..10f856f 100644 --- a/internal/env/env.go +++ b/internal/env/env.go @@ -105,6 +105,8 @@ func SetBuildEnv(projectPath string) { os.Setenv("GOPATH", GetGoPath(absPath)) os.Setenv("GOROOT", GetGoRoot(absPath)) os.Setenv("GOCACHE", GetGoCacheDir(absPath)) + os.Setenv("PKG_CONFIG_PATH", GetPythonPkgConfigDir(absPath)) + os.Setenv("CGO_ENABLED", "1") } func pathSeparator() string { @@ -114,13 +116,13 @@ func pathSeparator() string { return ":" } -// WriteEnvFile writes environment variables to .python/env.txt +// WriteEnvFile writes environment variables to .deps/env.txt func WriteEnvFile(projectPath, pythonHome, pythonPath string) error { // Prepare environment variables envVars := []string{ - fmt.Sprintf("PKG_CONFIG_PATH=%s", filepath.Join(pythonHome, "lib", "pkgconfig")), fmt.Sprintf("PYTHONPATH=%s", strings.TrimSpace(pythonPath)), fmt.Sprintf("PYTHONHOME=%s", pythonHome), + fmt.Sprintf("PATH=%s", GetPythonBinDir(projectPath)), } // Write to env.txt diff --git a/internal/env/env_test.go b/internal/env/env_test.go index 006fcb4..c89b87f 100644 --- a/internal/env/env_test.go +++ b/internal/env/env_test.go @@ -3,7 +3,6 @@ package env import ( "fmt" "os" - "path/filepath" "reflect" "runtime" "strings" @@ -106,7 +105,7 @@ func TestWriteEnvFile(t *testing.T) { // Verify the content contains expected environment variables envContent := string(content) expectedVars := []string{ - fmt.Sprintf("PKG_CONFIG_PATH=%s", filepath.Join(pythonDir, "lib", "pkgconfig")), + fmt.Sprintf("PATH=%s", GetPythonBinDir(projectDir)), fmt.Sprintf("PYTHONPATH=/mock/path1%s/mock/path2", pathSep), fmt.Sprintf("PYTHONHOME=%s", pythonDir), }