internal/rosa/python: pip helper
All checks were successful
Test / Create distribution (push) Successful in 1m29s
Test / Sandbox (push) Successful in 3m12s
Test / ShareFS (push) Successful in 4m25s
Test / Sandbox (race detector) (push) Successful in 5m44s
Test / Hakurei (race detector) (push) Successful in 6m55s
Test / Hakurei (push) Successful in 2m39s
Test / Flake checks (push) Successful in 1m23s

Binary pip releases are not considered acceptable, this more generic helper is required for building from source.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-19 00:03:36 +09:00
parent b081629662
commit 08dfefb28d

View File

@@ -81,6 +81,52 @@ func init() {
} }
} }
// PipHelper is the [Python] pip packaging helper.
type PipHelper struct {
// Whether to omit --no-build-isolation.
BuildIsolation bool
}
var _ Helper = new(PipHelper)
// extra returns python.
func (*PipHelper) extra(int) P { return P{Python} }
// wantsChmod returns true.
func (*PipHelper) wantsChmod() bool { return true }
// wantsWrite is equivalent to wantsChmod.
func (attr *PipHelper) wantsWrite() bool { return attr.wantsChmod() }
// scriptEarly is a noop.
func (*PipHelper) scriptEarly() string { return "" }
// createDir returns false.
func (*PipHelper) createDir() bool { return false }
// wantsDir requests a new directory in TMPDIR.
func (*PipHelper) wantsDir() string { return `"$(mktemp -d)"` }
// script generates the pip3 install command.
func (attr *PipHelper) script(name string) string {
if attr == nil {
attr = new(PipHelper)
}
var extra string
if !attr.BuildIsolation {
extra += `
--no-build-isolation \`
}
return `
pip3 install \
--no-index \
--prefix=/system \
--root=/work \` + extra + `
'/usr/src/` + name + `'`
}
// newViaPip installs a pip wheel from a url. // newViaPip installs a pip wheel from a url.
func (t Toolchain) newViaPip( func (t Toolchain) newViaPip(
name, version, url, checksum string, name, version, url, checksum string,