diff --git a/pkg/collector/python/init_windows.go b/pkg/collector/python/init_windows.go index 04d18175df1f7..47fed549c783f 100644 --- a/pkg/collector/python/init_windows.go +++ b/pkg/collector/python/init_windows.go @@ -9,8 +9,10 @@ package python import ( "os" + "path/filepath" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" + "github.com/DataDog/datadog-agent/pkg/util/winutil" ) // Any platform-specific initialization belongs here. @@ -21,5 +23,25 @@ func initializePlatform() error { os.Unsetenv("PYTHONPATH") } + // get program data directory and set PYTHONPYCACHEPREFIX + pd, err := winutil.GetProgramDataDir() + if err != nil { + return err + } + pycache := filepath.Join(pd, "python-cache") + + // check if path exists + if _, err := os.Stat(pycache); os.IsNotExist(err) { + // create the directory + if err := os.MkdirAll(pycache, 0755); err != nil { + return err + } + } else if err != nil { + return err + } + // TODO check if we have access to the directory ? + + os.Setenv("PYTHONPYCACHEPREFIX", pycache) + return nil } diff --git a/tools/windows/DatadogAgentInstaller/CustomActions/ConfigureUserCustomActions.cs b/tools/windows/DatadogAgentInstaller/CustomActions/ConfigureUserCustomActions.cs index 7b3479f2beb5d..7a5b6e03a93c3 100644 --- a/tools/windows/DatadogAgentInstaller/CustomActions/ConfigureUserCustomActions.cs +++ b/tools/windows/DatadogAgentInstaller/CustomActions/ConfigureUserCustomActions.cs @@ -632,9 +632,8 @@ private List PathsWithAgentAccess() Path.Combine(configRoot, "system-probe.yaml"), Path.Combine(configRoot, "auth_token"), Path.Combine(configRoot, "install_info"), - Path.Combine(_session.Property("PROJECTLOCATION"), "embedded2"), - Path.Combine(_session.Property("PROJECTLOCATION"), "embedded3"), - }; ; + Path.Combine(configRoot, "python-cache"), + }; } /// diff --git a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs index f7aaaf44ca494..46ab4dc2d0b88 100644 --- a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs +++ b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs @@ -552,6 +552,7 @@ private Dir CreateAppDataFolder() var appData = new Dir(new Id("APPLICATIONDATADIRECTORY"), "Datadog", new DirFiles($@"{EtcSource}\*.yaml.example"), new Dir("checks.d"), + new Dir("python-cache"), new Dir("run"), new Dir("logs"), new Dir(new Id("EXAMPLECONFSLOCATION"), "conf.d",