Skip to content

Commit

Permalink
Add python-cache file and remove embeded
Browse files Browse the repository at this point in the history
  • Loading branch information
jack0x2 committed Dec 13, 2024
1 parent dbce6c6 commit 34ef6e6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
22 changes: 22 additions & 0 deletions pkg/collector/python/init_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,8 @@ private List<string> 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"),
};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 34ef6e6

Please sign in to comment.