MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/buildpacks / mergeRequirementsFiles

Function mergeRequirementsFiles

pkg/python/python.go:736–757  ·  view source on GitHub ↗

mergeRequirementsFiles reads all files in reqs and appends their contents to dest file.

(reqs []string, dest string)

Source from the content-addressed store, hash-verified

734 return installRequirementsToTarget(ctx, targetPath, reqs, cmdBuilder)
735}
736
737func resolvePipTargetPaths(ctx *gcp.Context) (string, string) {
738 targetDir := PipTargetDir()
739 var targetPath string
740 if filepath.IsAbs(targetDir) {
741 targetPath = targetDir
742 } else {
743 targetPath = filepath.Join(ctx.ApplicationRoot(), targetDir)
744 }
745 return targetDir, targetPath
746}
747
748// mergeRequirementsFiles reads all files in reqs and appends their contents to dest file.
749func mergeRequirementsFiles(reqs []string, dest string) error {
750 destFile, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
751 if err != nil {
752 return fmt.Errorf("failed to open destination file: %w", err)
753 }
754 defer destFile.Close()
755
756 for _, req := range reqs {
757 content, err := os.ReadFile(req)
758 if err != nil {
759 return fmt.Errorf("failed to read requirements file %q: %w", req, err)
760 }

Callers 2

Calls 2

ReadFileMethod · 0.80
WriteMethod · 0.45

Tested by 1