Created
July 6, 2022 12:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove all but the latest N versions from wheels on Anaconda.org | |
# Usefult to avoid building up too many files when uploading | |
# developer wheels. | |
from binstar_client.utils import get_server_api | |
KEEP_N_LATEST = 10 | |
api = get_server_api(token=<TOKEN>) | |
package = api.package("astropy", "astropy") | |
# Find versions for which wheels are available | |
pypi_versions = set() | |
for file_info in package["files"]: | |
if file_info["type"] == "pypi": | |
pypi_versions.add(file_info["version"]) | |
pypi_versions = sorted(pypi_versions) | |
# Determine versions to remove | |
versions_to_remove = pypi_versions[:-KEEP_N_LATEST] | |
# Remove the files | |
for file_info in package["files"]: | |
if file_info["version"] in versions_to_remove: | |
print(f"Removing {file_info['basename']}") | |
api.remove_dist( | |
"astropy", | |
"astropy", | |
file_info["version"], | |
basename=file_info["basename"] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment