diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-19 00:03:36 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-19 00:03:36 +0900 |
| commit | 08dfefb28ddbc6e370743abf9c75275e2e3dcbdc (patch) | |
| tree | 86c1fd45dd87ed4d01584e46e61fa7f332a84225 | |
| parent | b081629662161cc9fd840df8709b662fe6292f0a (diff) | |
internal/rosa/python: pip helper
Binary pip releases are not considered acceptable, this more generic helper is required for building from source.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | internal/rosa/python.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/rosa/python.go b/internal/rosa/python.go index 4da4074d..e9a2a25a 100644 --- a/internal/rosa/python.go +++ b/internal/rosa/python.go @@ -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. func (t Toolchain) newViaPip( name, version, url, checksum string, |
