forked from rosa/hakurei
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>
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user