internal/rosa/python: use predictable URLs
All checks were successful
Test / Create distribution (push) Successful in 1m18s
Test / Sandbox (push) Successful in 3m25s
Test / Hakurei (push) Successful in 5m54s
Test / ShareFS (push) Successful in 5m53s
Test / Sandbox (race detector) (push) Successful in 7m30s
Test / Hakurei (race detector) (push) Successful in 9m6s
Test / Flake checks (push) Successful in 2m53s

This is much cleaner and more maintainable than specifying URL prefix manually. This change also populates Anitya project identifiers.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-13 02:08:22 +09:00
parent 46428ed85d
commit 0d449011f6

View File

@@ -100,26 +100,23 @@ pip3 install \
))) )))
} }
// newViaPip is a helper for installing python dependencies via pip. // newPypi creates [Metadata] for a [pypi] package.
func newViaPip( //
name, description, version, interpreter, abi, platform, checksum, prefix string, // [pypi]: https://pypi.org/
func newPypi(
name string, id int,
description, version, interpreter, abi, platform, checksum string,
extra ...PArtifact, extra ...PArtifact,
) Metadata { ) Metadata {
wname := name + "-" + version + "-" + interpreter + "-" + abi + "-" + platform + ".whl"
return Metadata{ return Metadata{
f: func(t Toolchain) (pkg.Artifact, string) { f: func(t Toolchain) (pkg.Artifact, string) {
return t.New(name+"-"+version, 0, t.AppendPresets(nil, return t.newViaPip(name, version, "https://files.pythonhosted.org/"+path.Join(
slices.Concat(P{Python}, extra)..., "packages",
), nil, nil, ` interpreter,
pip3 install \ string(name[0]),
--no-index \ name,
--prefix=/system \ name+"-"+version+"-"+interpreter+"-"+abi+"-"+platform+".whl",
--root=/work \ ), checksum, extra...), version
/usr/src/`+wname+`
`, pkg.Path(AbsUsrSrc.Append(wname), false, pkg.NewHTTPGet(
nil, prefix+wname,
mustDecode(checksum),
))), version
}, },
Name: "python-" + name, Name: "python-" + name,
@@ -127,6 +124,8 @@ pip3 install \
Website: "https://pypi.org/project/" + name + "/", Website: "https://pypi.org/project/" + name + "/",
Dependencies: slices.Concat(P{Python}, extra), Dependencies: slices.Concat(P{Python}, extra),
ID: id,
} }
} }
@@ -167,49 +166,39 @@ func init() {
} }
func init() { func init() {
artifactsM[PythonPygments] = newViaPip( artifactsM[PythonPygments] = newPypi(
"pygments", "pygments", 3986,
" a syntax highlighting package written in Python", " a syntax highlighting package written in Python",
"2.19.2", "py3", "none", "any", "2.19.2", "py3", "none", "any",
"ak_lwTalmSr7W4Mjy2XBZPG9I6a0gwSy2pS87N8x4QEuZYif0ie9z0OcfRfi9msd", "ak_lwTalmSr7W4Mjy2XBZPG9I6a0gwSy2pS87N8x4QEuZYif0ie9z0OcfRfi9msd",
"https://files.pythonhosted.org/packages/"+
"c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/",
) )
artifactsM[PythonPluggy] = newViaPip( artifactsM[PythonPluggy] = newPypi(
"pluggy", "pluggy", 7500,
"the core framework used by the pytest, tox, and devpi projects", "the core framework used by the pytest, tox, and devpi projects",
"1.6.0", "py3", "none", "any", "1.6.0", "py3", "none", "any",
"2HWYBaEwM66-y1hSUcWI1MyE7dVVuNNRW24XD6iJBey4YaUdAK8WeXdtFMQGC-4J", "2HWYBaEwM66-y1hSUcWI1MyE7dVVuNNRW24XD6iJBey4YaUdAK8WeXdtFMQGC-4J",
"https://files.pythonhosted.org/packages/"+
"54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/",
) )
artifactsM[PythonPackaging] = newViaPip( artifactsM[PythonPackaging] = newPypi(
"packaging", "packaging", 60461,
"reusable core utilities for various Python Packaging interoperability specifications", "reusable core utilities for various Python Packaging interoperability specifications",
"26.0", "py3", "none", "any", "26.0", "py3", "none", "any",
"iVVXcqdwHDskPKoCFUlh2x8J0Gyq-bhO4ns9DvUJ7oJjeOegRYtSIvLV33Bki-pP", "iVVXcqdwHDskPKoCFUlh2x8J0Gyq-bhO4ns9DvUJ7oJjeOegRYtSIvLV33Bki-pP",
"https://files.pythonhosted.org/packages/"+
"b7/b9/c538f279a4e237a006a2c98387d081e9eb060d203d8ed34467cc0f0b9b53/",
) )
artifactsM[PythonIniConfig] = newViaPip( artifactsM[PythonIniConfig] = newPypi(
"iniconfig", "iniconfig", 114778,
"a small and simple INI-file parser module", "a small and simple INI-file parser module",
"2.3.0", "py3", "none", "any", "2.3.0", "py3", "none", "any",
"SDgs4S5bXi77aVOeKTPv2TUrS3M9rduiK4DpU0hCmDsSBWqnZcWInq9lsx6INxut", "SDgs4S5bXi77aVOeKTPv2TUrS3M9rduiK4DpU0hCmDsSBWqnZcWInq9lsx6INxut",
"https://files.pythonhosted.org/packages/"+
"cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/",
) )
artifactsM[PythonPyTest] = newViaPip( artifactsM[PythonPyTest] = newPypi(
"pytest", "pytest", 3765,
"the pytest framework", "the pytest framework",
"9.0.2", "py3", "none", "any", "9.0.2", "py3", "none", "any",
"IM2wDbLke1EtZhF92zvAjUl_Hms1uKDtM7U8Dt4acOaChMnDg1pW7ib8U0wYGDLH", "IM2wDbLke1EtZhF92zvAjUl_Hms1uKDtM7U8Dt4acOaChMnDg1pW7ib8U0wYGDLH",
"https://files.pythonhosted.org/packages/"+
"3b/ab/b3226f0bd7cdcf710fbede2b3548584366da3b19b5021e74f5bde2a8fa3f/",
PythonIniConfig, PythonIniConfig,
PythonPackaging, PythonPackaging,
PythonPluggy, PythonPluggy,