-
Notifications
You must be signed in to change notification settings - Fork 14
ENG-2084: Install private wheels into the Python runtime's site-packages #3850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4e30b68
c41a66d
9054514
e8954f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package runtime | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/ActiveState/cli/pkg/sysinfo" | ||
| ) | ||
|
|
||
| func mkSitePackages(t *testing.T, root, rel string) { | ||
| t.Helper() | ||
| if err := os.MkdirAll(filepath.Join(root, rel), 0700); err != nil { | ||
| t.Fatalf("MkdirAll: %v", err) | ||
| } | ||
| } | ||
|
|
||
| func TestGlobSitePackages(t *testing.T) { | ||
| // The expected layout is OS-specific (see sitePackagesGlob). | ||
| layout := filepath.Join("usr", "lib", "python3.10", "site-packages") | ||
| if sysinfo.OS() == sysinfo.Windows { | ||
| layout = filepath.Join("Lib", "site-packages") | ||
| } | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| layout string // relative dir to create under the root, "" for none | ||
| want string // expected relative site-packages path, "" for no match | ||
| }{ | ||
| {"matching layout", layout, layout}, | ||
| {"no site-packages", filepath.Join("bin"), ""}, | ||
| {"unexpected layout not globbed", filepath.Join("opt", "python", "site-packages"), ""}, | ||
| } | ||
|
Comment on lines
+18
to
+33
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional — the tests track the deterministic per-OS layout the alternative-builder runtimes actually use (see the reply on |
||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| root := t.TempDir() | ||
| if tt.layout != "" { | ||
| mkSitePackages(t, root, tt.layout) | ||
| } | ||
| got := globSitePackages([]string{root}) | ||
| if tt.want == "" { | ||
| if len(got) != 0 { | ||
| t.Fatalf("expected no candidates, got %v", got) | ||
| } | ||
| return | ||
| } | ||
| if len(got) != 1 || got[0] != tt.want { | ||
| t.Fatalf("expected [%s], got %v", tt.want, got) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestGlobSitePackagesDeduplicatesAcrossRoots(t *testing.T) { | ||
| rootA := t.TempDir() | ||
| rootB := t.TempDir() | ||
| rel := filepath.Join("usr", "lib", "python3.10", "site-packages") | ||
| if sysinfo.OS() == sysinfo.Windows { | ||
| rel = filepath.Join("Lib", "site-packages") | ||
| } | ||
| mkSitePackages(t, rootA, rel) | ||
| mkSitePackages(t, rootB, rel) | ||
|
|
||
| got := globSitePackages([]string{rootA, rootB}) | ||
| if len(got) != 1 || got[0] != rel { | ||
| t.Fatalf("expected a single deduplicated [%s], got %v", rel, got) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a deliberate scoping decision.
prepare_mac.gois part of the camel (legacy) builder path, which is entirely separate from this feature —state publish --buildprivate ingredients flow through the modern alternative builder (thesetup.godeploy path), whose runtimes are relocated under a single install root with a deterministic layout:usr/lib/pythonX.Y/site-packageson Linux/macOS andLib/site-packageson Windows. That per-OS layout was confirmed by the team, which is why this collapses to one pattern per OS rather than enumerating camel's framework layouts.The behavior on an unmatched layout is intentional:
locateSitePackagesreturns an error and the install fails fast rather than silently landing the wheel somewhere wrong. If a private ingredient ever targets a runtime with a different layout, that error is the signal to extendsitePackagesGlob— better than guessing.