Skip to content

Commit

Permalink
In pip vendored dependencies, show clear message if FF is missing fro…
Browse files Browse the repository at this point in the history
…m requirements.txt.

PiperOrigin-RevId: 569326761
Change-Id: Ieda33142f8a3b4db068d0aec86d7fd3b8e2e9203
  • Loading branch information
kritkasahni-google authored and copybara-github committed Sep 28, 2023
1 parent 8bdbb0e commit f6ecd43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builders/python/acceptance/gcf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ func TestFailures(t *testing.T) {
Env: []string{"GOOGLE_SKIP_FRAMEWORK_INJECTION=True"},
MustMatch: "skipping automatic framework injection has been enabled",
},
{
Name: "use pip vendored deps - framework not vendored",
App: "without_framework",
Env: []string{"GOOGLE_VENDOR_PIP_DEPENDENCIES=vendor"},
MustMatch: "Vendored dependencies detected, please add functions-framework to requirements.txt and download it using pip",
},
}

for _, tc := range acceptance.FilterFailureTests(t, testCases) {
Expand Down
3 changes: 3 additions & 0 deletions cmd/python/functions_framework/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func buildFn(ctx *gcp.Context) error {
return fmt.Errorf("clearing layer %q: %w", l.Name, err)
}
} else {
if _, isVendored := os.LookupEnv(python.VendorPipDepsEnv); isVendored {
return gcp.UserErrorf("Vendored dependencies detected, please add functions-framework to requirements.txt and download it using pip")
}
ctx.Logf("Handling functions without dependency on functions-framework.")
if err := cloudfunctions.AssertFrameworkInjectionAllowed(); err != nil {
return err
Expand Down

0 comments on commit f6ecd43

Please sign in to comment.