]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/dev/tasks/conda-recipes/clean.py
1 from subprocess
import check_output
, check_call
2 from typing
import List
9 from packaging
.version
import Version
28 ["r-arrow", "linux-aarch64"],
32 def packages_to_delete(package_name
: str, platform
: str) -> List
[str]:
33 env
= os
.environ
.copy()
34 env
["CONDA_SUBDIR"] = platform
35 pkgs_json
= check_output(
42 "--override-channels",
47 pkgs
= pd
.DataFrame(json
.loads(pkgs_json
)[package_name
])
48 pkgs
["version"] = pkgs
["version"].map(Version
)
49 pkgs
["py_version"] = pkgs
["build"].str.slice(0, 4)
53 for (subdir
, python
), group
in pkgs
.groupby(["subdir", "py_version"]):
54 group
= group
.sort_values(by
="version", ascending
=False)
56 if len(group
) > VERSIONS_TO_KEEP
:
57 del_candidates
= group
[VERSIONS_TO_KEEP
:]
59 f
"arrow-nightlies/{package_name}/"
60 + del_candidates
["version"].astype(str)
61 + del_candidates
["url"].str.replace(
62 "https://conda.anaconda.org/arrow-nightlies", ""
69 if __name__
== "__main__":
71 for package
in PACKAGES
:
72 for platform
in PLATFORMS
:
73 if [package
, platform
] in EXCLUDED_PATTERNS
:
75 to_delete
+= packages_to_delete(package
, platform
)
77 for name
in to_delete
:
78 print(f
"Deleting {name} …")
79 if "FORCE" in sys
.argv
:
80 check_call(["anaconda", "remove", "-f", name
])