OpenAstronomy/publish-wheels-anaconda

Improve sorting of versions to remove

Closed this issue · 4 comments

The script for removing old wheels sorts the version strings alphanumerically:

pypi_versions = sorted(pypi_versions)

This should be fine in most case, but if a version changes from single to double digits (e.g. 1.9.0 to 1.10.0, or 2022.9.1 to 2022.10.1) it'll delete the newest version instead. We should write a function to pass as a key to sorted. Probably, drop leading characters such as v, split on ., - and + into a tuple, and convert to an integer if only digits.

This actually manifested as a horrible bug in astropy, see astropy/astropy#15935 .

pypi_versions = sorted(pypi_versions)
# Determine versions to remove
versions_to_remove = pypi_versions[:-keep]

It kept a very old dev98 but deleted the dev359 that it was supposed to upload. I had to disable this feature in astropy until this is fix at the risk of filling up the disk quota.

Any chance this will get fixed soon?

Maybe we could also sort on upload date if there is a way to get that information.

Good point. Upload date would be ideal as that would allow for patches to older major releases.

Just had a look at the JSON the API returns. Each file has an upload_time with a value e.g. 2018-10-19 19:03:58.717000+00:00. I'll open a PR that parses and then sorts based on the upload time.